Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Web Services and the fly likes Consuming REST service using JDK API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Consuming REST service using JDK API " Watch "Consuming REST service using JDK API " New topic
Author

Consuming REST service using JDK API

Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 135
Hi,

I have created REST WS (producer) using jersey, to consume the REST can i use JDK net package like URL or URLHttpConnection to consume the REST WS rather than creating the REST client API to consume it? So that irrespective of the REST implementer the client will always use the same JDK API to consume the REST WS. Please clarify.

Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
Yes, the classes built into the JRE are sufficient. However, clients may wish to use a library like Apache HttpClient instead.


Ping & DNS - my free Android networking tools app
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
Note that since REST is an architectural style for addressing resources rather than a messaging API, I don't think it possible to come up with a universal client.

A simple GET request could return any resource from an XML document to an encrypted image. Just for a start, consider all the resource types a web browser might GET for a single page.

Then we get into POST, PUT, DELETE, etc etc. - in any case, the JDK will be sufficient for generating the request, but handling the resource returned may require a specialized library.

Bill

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Consuming REST service using JDK API
 
Similar Threads
REST webservice consumers should change their API to support REST
Readonly Web services
REST WS in place of SOAP
Java 7 JAX-WS: Is JAX-WS an API or implementation?
Issues related to RESTful web servicers