开发者

Problem to use GWT client to call a Restlet web service

开发者 https://www.devze.com 2023-02-12 02:26 出处:网络
I am using Restlet framework, and I want to use GWT as the client side. I have already created some ServerResources in Restlet. Here is the codes for the GWT client:

I am using Restlet framework, and I want to use GWT as the client side. I have already created some ServerResources in Restlet. Here is the codes for the GWT client:

BookResourceProxy.java

public interface BookResourceProxy extends ClientProxy { @Get public void getBooks(Result callback); }

The class that use this Proxy:

BookResourceProxy wrp = GWT.create(BookResourceProxy.class);

wrp.getClientResource().setReference("/Books");

wrp.getClientResource().getClientInfo().getAcceptedMediaTypes().add(new
Preference<MediaType>(MediaType.APPLICATION_JSON));


wrp.getBooks(new Result<String>() 
    {
  public void onFailure(Throwable caught) 
  {
    Window.alert("Fail" + caught.getMessage());
  }

  public void onSuccess(String json) 
  {
    Window.alert(json);
  }
});

When I run the application, I always receive the error:

"No source code is available for type org.restlet开发者_如何学运维.resource.ClientProxy; did you forget to inherit a required module?"

But if I inherit it in the .gwt.xml:

Another error occurs:

Unable to find 'org/restlet/Restlet.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source? [ERROR] Line 13: Unexpected exception while processing element 'inherits'

Does anybody know why?

Thanks in advance!

Ike


Make sure you are using the GWT edition of Restlet and that org.restlet.jar is in the GWT compiler's classpath.


In GWT side you'll have to use package org.restlet.client.*, on GAE side you use org.reslet.

0

精彩评论

暂无评论...
验证码 换一张
取 消