Link to home
Start Free TrialLog in
Avatar of szilora
szilora

asked on

Java client for RESTful service

I'm trying to write a java client to access a restful service without using jersey or other libs. Using HttpURLConnection works great. I can hit the service and get a result back. I can also use the setRequestMethod() to specify whether I'm doing a GET, POST, etc.

What I cannot figure out how to do is specify the return content-type. That is, for a service that can return either application/xml or application/json (or other types), how do I specify which one I want back? I can use addRequestProperty("Content-Type","application/xml") to say what I'm sending in the request, but how to I specify content type for the response?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of szilora
szilora

ASKER

Super! Thanks.