サーバー上にいくつかの REST サービス (Jetty、RESTeasy) と GWT クライアントがあります。フロントエンドで Restlet-GWT モジュールを使用することにしました。
JSE クライアント (RESTeasy クライアント) を作成しましたが、サービスが適切に呼び出され (Jetty サーバーのログに SQL トレースが表示されます)、xml 応答が返されます。
次に、RestletでGWTから試しました。Web サービス (Jetty log) が呼び出されますが、null 応答があります。
Web サービス (バックエンド):
@GET
@Path("/getArt/{id}")
@Produces("application/xml")
public Art getArt(@PathParam("id")int id){
Art art= artDAO.findById(id);
return art;
}
フロントエンド GWT :
public class Front_End implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Client client = new Client(Protocol.HTTP);
client.get("http://localhost:8080/rest/service/getArt/1", new Callback() {
@Override
public void onEvent(Request request, Response response) {
System.out.println("Reponse : " + response.getEntity().getText());
}
});
}
RESTeasy クライアントの動作:
public Object test(int id){
try {
ClientRequest request = new ClientRequest("http://localhost:8080/rest/service/getArt/"+id);
request.accept("application/xml");
ClientResponse<String> response = request.get(String.class);
if (response.getStatus() == 200)
{
Unmarshaller un = jc.createUnmarshaller();
Object o = un.unmarshal(new StringReader(response.getEntity()));
return o;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
RESTeasy と Restlet は「互換性」がありますか? バックエンドで RESTeasy の代わりに Restlet を使用する必要がありますか? 私は何が欠けていますか?
事前にThx