0

Is there any way I can access RESTful webservice using a servlet. I dont want to use Jersey client?
EDIT: How can I pass object in the url and make sure that marshalling/unmarshalling is done properly?

3 Answers 3

1

You can use the commons-httpclient library (http://hc.apache.org/httpcomponents-client-ga/) to make a request to your REST service, and gson (http://code.google.com/p/google-gson/) to serialize/deserialize java objects to JSON

Sign up to request clarification or add additional context in comments.

Comments

0

You could code your own HTTP requests e.g. using HTTPURLConnection. Here you can set the request method and change the URL or/and body as appropiate e.g.

   URL url = new URL("http://www.example.com/resource");
   HttpURLConnection connection = (HttpURLConnection) url.openConnection();
   connection.setRequestMethod("GET");
  // etc

This way you're just using the standard java.net API.

Comments

0

You don't need to use jersey client, it's just a URL, you can use:

new URL("http://locationofservice").openConnection();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.