why does HTTPClient response produce JSON stream, when the same GET request in the browser shows XML response?
I am using HttpClient for the first time to开发者_Python百科 make a request to a web service (defined by WADL), I'd like to unmarshall the response into a meaningful object, in the browser if I perform the Get request it response with XML. But when I display the response from the code it seems to be JSON. Am I missing a step? or is there a way this can be converted?
Is it possible that the browser and the code are sending different Accept:
headers? http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
Can you try sending an Accept header of "application/xml, text/xml", say, from the code and see if that changes things? Another thing to do is to check the headers the browser is sending using a tool like Firebug, for example, because if the URL is the same, it's almost certainly one of the headers being sent that's changing the behaviour.
I'm guessing the webservice is returning a different response depending on the user-agent or something else different about the request. Check all teh parameters are identical. Also check the HttpClient is doing a GET not a POST. There should be no difference in the response unless parameters or headers differ between your web-browser and your HttpClient request.
精彩评论