Consuming REST services

31 views
Skip to first unread message

Pascal Robert

unread,
May 18, 2011, 9:05:39 AM5/18/11
to WebObjects Development
Good morning,

I see from the 2011 surveys that a good part of the community is consuming REST services. I was wondering what are you using to consume those? Right now, I'm playing with ERXRestClient and JBoss' RestEasy to consume REST services, but I'm curious to see what other people use. Just plain Jakarta HTTPClient with a JSON or XML parser?


--
Pascal Robert
pro...@macti.ca

WOWODC 2011 : July 1-2-3, Montreal. wowodc.com

AIM/iChat : MacTICanada
LinkedIn : http://www.linkedin.com/in/macti
Twitter : pascal_robert

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobje...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/webobjects-dev-garchive-31333%40googlegroups.com

This email sent to webobjects-dev...@googlegroups.com

Henrique Prange

unread,
May 18, 2011, 9:20:07 AM5/18/11
to WebObjects Development
Hi Pascal,

We have been using Jersey [1] to produce and consume REST services. We found Jersey the most concise and simple REST implementation. It also offers a good set of tools to test production and consumption of REST services, which is essential in our development process.

[1]http://jersey.java.net/

Cheers,

Henrique

On 18/05/2011, at 10:05, Pascal Robert wrote:

> Good morning,
>
> I see from the 2011 surveys that a good part of the community is consuming REST services. I was wondering what are you using to consume those? Right now, I'm playing with ERXRestClient and JBoss' RestEasy to consume REST services, but I'm curious to see what other people use. Just plain Jakarta HTTPClient with a JSON or XML parser?
>
>
> --
> Pascal Robert
> pro...@macti.ca
>
> WOWODC 2011 : July 1-2-3, Montreal. wowodc.com
>
> AIM/iChat : MacTICanada
> LinkedIn : http://www.linkedin.com/in/macti
> Twitter : pascal_robert
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (Webobje...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:

> http://lists.apple.com/mailman/options/webobjects-dev/hprange%40gmail.com
>
> This email sent to hpr...@gmail.com

Kieran Kelleher

unread,
May 18, 2011, 9:20:52 AM5/18/11
to Pascal Robert, WebObjects Development
Currently HttpClient and SAX XML Parsers. Open to using a rest library as long as it is not unreliable and over-complicated.

On May 18, 2011, at 9:05 AM, Pascal Robert wrote:

> Good morning,
>
> I see from the 2011 surveys that a good part of the community is consuming REST services. I was wondering what are you using to consume those? Right now, I'm playing with ERXRestClient and JBoss' RestEasy to consume REST services, but I'm curious to see what other people use. Just plain Jakarta HTTPClient with a JSON or XML parser?
>
>
> --
> Pascal Robert
> pro...@macti.ca
>
> WOWODC 2011 : July 1-2-3, Montreal. wowodc.com
>
> AIM/iChat : MacTICanada
> LinkedIn : http://www.linkedin.com/in/macti
> Twitter : pascal_robert
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (Webobje...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:

> http://lists.apple.com/mailman/options/webobjects-dev/kelleherk%40gmail.com
>
> This email sent to kell...@gmail.com

Henrique Prange

unread,
May 18, 2011, 9:39:48 AM5/18/11
to WebObjects Development
Pascal,

Just to summarize the simplicity of Jersey client. Here is a sample code of how to do a GET on the resource identified by 10.

Client client = Client.create();

WebResource resource = client.resource( "http://localhost/my-service" );

MyResource response = resource.path("resource").path(10).type(MediaType.APPLICATION_JSON).get(MyResource.class);

Cheers,

Henrique

Pascal Robert

unread,
May 18, 2011, 10:05:03 AM5/18/11
to Henrique Prange, WebObjects Development
Le 2011-05-18 à 09:39, Henrique Prange a écrit :

Pascal,

Just to summarize the simplicity of Jersey client. Here is a sample code of how to do a GET on the resource identified by 10.

Client client = Client.create();

WebResource resource = client.resource( "http://localhost/my-service" );

MyResource response = resource.path("resource").path(10).type(MediaType.APPLICATION_JSON).get(MyResource.class);

RestEasy is not too bad :

public interface SimpleClient {
  
  @GET
  @Path("search.json")
  @Produces("application/json")
  ClientResponse<TwitterSearchResult> getSearchResults(@QueryParam("q") String hashtag, @QueryParam("result_type") String resultType);

  

}
    SimpleClient client = ProxyFactory.create(SimpleClient.class, "http://search.twitter.com/");
    ClientResponse<TwitterSearchResult> response = client.getSearchResults("#wowodc","recent");
    if (response.getResponseStatus().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
      NSLog.out.appendln(response.getEntity());
    } 

Problem is that it doesn't understand classes like NSTimestamp and NSArray. ERXRestClient understand the WO unique stuff, but you have to write delegates, use ERXKeyFilter, etc. But ERXRestClient is good if the service you call is the service you are calling are following the same structure as ERRest or RoR.

BTW, the Twitter REST API is crap.

Mike Schrag

unread,
May 18, 2011, 10:21:13 AM5/18/11
to Pascal Robert, WebObjects Development
ERXRestClient was just a proof of concept ... There's really no reason you couldn't just extend the APi to always use ERXKeyFilter.filterWithAllRecursive() and make a default rest delegate that just makes new instances of classes for you. That said, I think RestEasy and Jersey both do a better job on the client side for things like modeling cookie, header, and form parameters. All would be pretty easy to put into ERXRestClient, though -- we certainly have all the primitives to do it.

ms

Pascal Robert

unread,
May 18, 2011, 10:36:24 AM5/18/11
to Mike Schrag, WebObjects Development
Le 2011-05-18 à 10:21, Mike Schrag a écrit :

ERXRestClient was just a proof of concept ... There's really no reason you couldn't just extend the APi to always use ERXKeyFilter.filterWithAllRecursive() and make a default rest delegate that just makes new instances of classes for you. That said, I think RestEasy and Jersey both do a better job on the client side for things like modeling cookie, header, and form parameters. All would be pretty easy to put into ERXRestClient, though -- we certainly have all the primitives to do it.

What about using the JSON parser from ERRest to make it work with RestEasy? Right now, I'm using the Jackson parser and it look like we could use any JSON parser instead of JSON. That's something I could work on.

Mike Schrag

unread,
May 18, 2011, 11:00:07 AM5/18/11
to Pascal Robert, WebObjects Development
it's not really an issue of parsing, it's an issue of mapping that parsed structure onto classes ... i don't know where that lives. seems easier to just add whatever's missing into ERXRestClient, or look into adding custom serializers/deserializers into resteasy. or even better, if you're sending JSON, why do you even care that it's an NSArray? it should just turn into a List on the client ...

ms

Farrukh Ijaz

unread,
May 18, 2011, 12:26:21 PM5/18/11
to Mike Schrag, WebObjects Development
Hi, I wish I could use ERXKeyFilter.filterWithAllRecursive() but it takes forever for some entities. I guess it's because of 2 way relationship causes the call to get into an infinite loop?

I am quite satisfied with the ERRest framework. We are using it heavily for iPhone / iPad apps. The built in support for plist is quite handy so never got chance to use JSON or XML format. Perhaps would use it for building Android and Blackberry clients.

Farrukh

Sent from my iPad 2

Mike Schrag

unread,
May 18, 2011, 12:30:09 PM5/18/11
to Farrukh Ijaz, WebObjects Development
I mean specifically on the client, where you probably have "synthetic" model classes ... You almost NEVER want all-recursive on the server. It should be smart enough to not infinite loop, but you could traverse your entire database, depending on your relationships.

ms

Pascal Robert

unread,
May 18, 2011, 1:23:15 PM5/18/11
to Mike Schrag, WebObjects Development
Le 2011-05-18 à 11:00, Mike Schrag a écrit :

it's not really an issue of parsing, it's an issue of mapping that parsed structure onto classes ... i don't know where that lives. seems easier to just add whatever's missing into ERXRestClient, or look into adding custom serializers/deserializers into resteasy. or even better, if you're sending JSON, why do you even care that it's an NSArray? it should just turn into a List on the client ...

Anything that can be done before WOWODC :-) 

Matthew Ness

unread,
May 19, 2011, 7:11:26 PM5/19/11
to Pascal Robert, WebObjects Development
> Good morning,
>
> I see from the 2011 surveys that a good part of the community is consuming
> REST services. I was wondering what are you using to consume those? Right
> now, I'm playing with ERXRestClient and JBoss' RestEasy to consume REST
> services, but I'm curious to see what other people use. Just plain Jakarta
> HTTPClient with a JSON or XML parser?
>
>

Hi Pascal,

Java (SAX), consuming XML
Flex and AIR, consuming XML and JSON

--
Matt.

http://logicsquad.net/

Reply all
Reply to author
Forward
0 new messages