aspose file tools*
The moose likes Web Services and the fly likes How to access the JSON reponse from a java client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to access the JSON reponse from a java client " Watch "How to access the JSON reponse from a java client " New topic
Author

How to access the JSON reponse from a java client

Dwijen Bhattacharjee
Greenhorn

Joined: Mar 31, 2008
Posts: 26
Hi All,
I have very basic knowledge of webservice. Currently I am trying to convert the response of a Webservice as JSON . I follow the steps mentioned in the [url]http://www.marcusschiesser.de/?p=130 [/url] link. Now I am getting the response as a JSON object . But the problem I am facing is that how to access the response from a java client . I only know the use of OMElement to access the response from a webservice . so whenever I am trying to access the Webservice using OMElement from java clent its throwing an exception that "Unexpected chracter {.... expected <" . As per my understanding OMElement expects XML so it's expecting a response which started with < charecter , as my webservice's response is JSON .So it throws the exception. My question is how can i access the JSON response from java client ?? It will be better if you will post some code snippet.
Srikanth Kumar
Ranch Hand

Joined: Jun 04, 2008
Posts: 36
Make use of the thoughtworks XStram API to convert the webservice response to JSON string.

Download this from http://xstream.codehaus.org/download.html

And the sample code will be like this.



This link is also useful.

http://xstream.codehaus.org/json-tutorial.html


Srikanth Kumar
SCJP 5, SCWCD 5, SCDJWS 5
Dwijen Bhattacharjee
Greenhorn

Joined: Mar 31, 2008
Posts: 26
Thank You Srikanth
 
jQuery in Action, 2nd edition
 
subject: How to access the JSON reponse from a java client