What do you mean by "you guess"? It would be the correct status code if the URL you're trying to access did not exist. If it does exist, and the WS call returns something other than a 404, then it would be incorrect.
Joined: Aug 19, 2005
Originally posted by abhijeet: currently i am using this method - webResource.head().getResponseStatus().getStatusCode()
but it is always returning 404 code, which i guess is not correct.
Basically you are invoking an HTTP HEAD request on the resource/URL and the server complains that the URL doesn't exist.
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
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.
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 ]