Hi JR,

There is indeed a lack of documentation in this area. It's still very recent
features. You can get automatic conversion for retrieved representations
like this:

  String myString = myClientResource.get(String.class);

For sent representations:

  myClientResource.put(myString);

There is even a more transparent way if you define an annotated Java
interface (using the Restlet @Get, @Put, etc. annotations). Once it is
defined, you can use it on the server side in your ServerResource subclasses
or on the client side to consume it:

  MyAnnotatedInterface myClient =
myClientResource.wrap(MyAnnotatedInterface.class);

In this case, automatic conversion is handled for you. See the attached
sample files for more guidance.

We are looking for feed-back on those features, so don't hesitate.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : JR Shampang [mailto:[email protected]] 
Envoyé : lundi 24 août 2009 23:05
À : [email protected]
Objet : ClientResource Examples?

Is there any documentation or examples out there for using the Restlet API
to consume a REST service? The only example I found is on the "First
Resource" page
(http://www.restlet.org/documentation/2.0/firstResource#part07), and that's
only a very basic example of it.

More specifically, I'd like to know:

How do you use the ConverterService to convert objects to/from XML/JSON/etc?

What is the recommended practice for using Restlet to build a REST client?

Is there a tool available for auto-generating Restlet client code?

ClientResource.getResponseEntity() returns a Representation only on the
first call to the method. Why, and what other "gotchas" are there when using
ClientResource and consuming REST services?

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

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

Attachment: TestClientResource.java
Description: Binary data

Attachment: TestResource.java
Description: Binary data

Attachment: TestServerResource.java
Description: Binary data

Reply via email to