Here is a code snippet that I found in jersey/samples/entityprovider/src/test/java/com/sun/jersey/samples/entityprovider/MainTest.java
Hope this helps
so
should work.
Note that as far as I know JSR-311 is only a
server API. The
Jersey Client API was simply created for
testing but is not part of JSR-311 which is why it lives in the proprietary
com.sun.jersey.api.client package (it used to be in com.sun.ws.rest.api.client). This leaves it up to the client developer to decide what level of coupling to the server is appropriate.
So you may actually want to look into using something like the
Jarkarta Commons HttpClient to access the resource on the server.
(Apparently
Java SE 6
java.net.HttpURLConnection has improved considerably since J2SE 1.4.2 (
Comparison)).
Now lets say that the representation is sent to you in XML or XHTML. Rather than doing a full blown
XML-Schema validated parse on the document you may want to consider using XPath instead to just get at the few parts that are of interest to you. That way your client may actually continue to work even if other parts of the representation evolve. Its a little more complicated and requires a little more thought but that is the price of loose coupling.
[ November 11, 2008: Message edited by: Peer Reynders ]