Hello,

if you want to coonsume JSON representation, you need the "json" extension
of the GWT edition.
You can have more details here :
http://wiki.restlet.org/docs_2.1/190-restlet.html

Having said that, I suggest that you add the gwt *extension* to your server
project. By doing so, the hosted resources will be given the ability
generate and accept representations based on the GWT serialization format.
In that case, the core module is only required on GWT-client side.

All of this is based on the usage of Converters (provided by the jackson and
gwt extensions on server side) in conjunction with definition of this kind
of resources:
public class CatalogResource extends ServerResource {
       private SolrService solrService;
       @Get
       public Plafonnier getAllPlafonniers(){
          return (solrService.getAllPlafonniers().get(0));
       }
}

The "@Get" method simply returns an object, that is converted to a
Representation based on the available Converters and the client preferences.

This page illustrates this kind of needs :
http://wiki.restlet.org/docs_2.1/303-restlet.html

Best regards,
Thierry Boileau

Hi all,
>
> Before add RESTLET on our project, I actually did a poc on it.
>
> My architecture is:
>
> -A server which expose some Rest services (Restlet,Maven,Spring,Jetty)
> -A Java SE client (Restlet)
> -A GWT client
>
>
> The communication is OK between my jetty server and JSE client. I get my
> Json
> datas without problem.
>
> My issue is on the GWT client, I can't get my data from my Jetty Server.
>
> Here my restlet configuration:
> *********************
> -SERVER JETTY (Expose services in REST)
> *********************
>
> import org.restlet.ext.jackson.JacksonRepresentation;
> import org.restlet.representation.Representation;
> import org.restlet.resource.Get;
> import org.restlet.resource.ServerResource;
>
> import com.mycompany.myproject.service.SolrService;
>
>
> public class CatalogResource extends ServerResource {
>
>        private SolrService solrService;
>
>        @Get
>        public Representation getAllPlafonniers(){
>                return new JacksonRepresentation<Plafonnier>
> (solrService.getAllPlafonniers().get(0));
>        }
>
> ***************************
> -GWT CLIENT (my issue)
> ***************************
> ....
> import org.restlet.client.Client;
> import org.restlet.client.Request;
> import org.restlet.client.Response;
> import org.restlet.client.Uniform;
> import org.restlet.client.data.MediaType;
> import org.restlet.client.data.Method;
> import org.restlet.client.data.Preference;
> import org.restlet.client.data.Protocol;
> .....
>
> public void onClick(ClickEvent event) {
>
> final Client client = new Client(Protocol.HTTP);
>
> Request r=new Request(Method.GET,"http://localhost:8080/myproject/hello";);
>
> r.getClientInfo().getAcceptedMediaTypes().add(new Preference<MediaType>
> (MediaType.APPLICATION_JSON));
>
> client.handle(r,new Uniform() {
>        public void handle(Request request,Response response) {
>        try {
>               if(response.getEntity()!=null)
>                 System.out.println("Json=
> "+response.getEntity().getText());
>               else
>                  System.out.println("No response entity");
>
>             } catch (Exception e) {
>                        e.printStackTrace();
>        }
>
>        }
>  });
>
> ____________________________________________________________
>
> When I execute this code, I can see on the log jetty server that it receive
> a
> request but on my gwt client the response.getEntity() is always NULL !
>
> I don't know where is my mistake, I tried differents syntaxes but no
> result.
> When I use ClientProxy syntaxe I have "Internal Connector Error (1002)...".
>
> When I try it with JSE client or directly with my browser I receive my Json
> datas without problem.
>
>
> Can somebody give me light on this issue ?
>
>
> My libraries version:
>
> --On Server
> <dependency>
>      <groupId>org.restlet.jee</groupId>
>      <artifactId>org.restlet</artifactId>
>      <version>2.0.1</version>
>    </dependency>
>
> --On Gwt client
> <dependency>
>      <groupId>org.restlet.gwt</groupId>
>      <artifactId>org.restlet</artifactId>
>      <version>2.1-M2</version>
>    </dependency>
>
>
>
> Thanks a lot.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2710886
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2711988

Reply via email to