File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Consuming REST service using JDK API " Watch "Consuming REST service using JDK API " New topic

Consuming REST service using JDK API

Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 181

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.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Yes, the classes built into the JRE are sufficient. However, clients may wish to use a library like Apache HttpClient instead.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
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.


I agree. Here's the link:
subject: Consuming REST service using JDK API
It's not a secret anymore!