• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Invoking REST webservices.

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to REST webservices. We have a need to invoke REST webservices. Which tools/frameworks can we use? I heard about Jersey, Wink, Axis2,
etc, but do not know them in detail. Please suggest/let me know the popular and best tool for invoking REST webservices.

--venkat
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jersey is the reference implementation of the JAX-RS API, so I'd start by looking into that.

While Axis2 can be used as client to any web service, it doesn't support JAX-RS specifically, which would rule it out in my book. It's really a SOAP stack, and that's what one should use it for.
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Three other web service stacks that support JAX-RS are:
- Apache CXF http://cxf.apache.org/
With XML and JSON data binding "out of the box".
- RESTlet http://www.restlet.org/
Very lightweight and easy to use. My first choice if I am to quickly get a standalone (not running in any kind of container) RESTful webservice up and running.
With the Grizzly extension it also works very well under quite heavy load.
- JBoss RESTeasy http://www.jboss.org/resteasy/
Regretfully, I don't have any experiences with this one yet.
Best wishes!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IF all you are doing is GET operations, plain old Java may be sufficient with HttpURLConnection.

IF you are dealing with big name REST servers like Yahoo or Amazon or Google, you can probably find great sample code in a variety of languages on their site.

Bill
 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi William

We are in a process of calling a .NET Rest WS which returns back an xml document

We are also evaluating the best framework which we can use since our requirement is to only do a pull and we are not creating any Rest service.
Any opinion which way to approach it.

There are many framework in the market like Jersey, Restlet etc...

Thanks
darniz
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see no need for a "Framework" at all. The standard Java library has all you need - for example HttpURLConnection.

Do a GET, grab the return as a stream, input to standard XML parser and boom - you got a DOM that you can pick at with standard XPath etc etc.

It really is that simple. Which is why so many people are wondering exactly why they got so deeply involved with some framework.

Bill

 
Darvesh Niz
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank a lot
Thats whats i thought about it.
just wanted to get an opinion about it.

darniz
 
Darvesh Niz
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The other question is that how can i handle connection timeout if i adopt this approach.

Rashid
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
The failure to issue a request to a RESTful web service can be handled in a number of ways, depending on the requirements of your application. For example:
- Log the error and discard the request.
- Implement a retry mechanism that retries failed requests a certain number of times, perhaps with a certain delay between the retries.
- Use queuing and remove a request from the queue only when a request has been successfully issued.
If a request fails, it can be put to the end, or some other location, of the queue and it will thus be retried after some time.

Best wishes!
 
Darvesh Niz
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks

i might be using apache httpclient so that i can also put timeout on the request, since i dont want my invoker to wait for an unlimited time if hte response is too slow.

Apart from that all other issue like badurl etc.. can be handled.

darniz
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
You can refer to the url below, and I believe it will be useful.
http://www.devx.com/Java/Article/40659
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried using Apache Wink and it seems to be pretty simple - I was able to run a simple program within minutes.
 
reply
    Bookmark Topic Watch Topic
  • New Topic