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