You can use it in a managed bean without any problems. RESTful web services typically return JSON or XML format objects. You can call a soothing web service and, depending on the format of its response, parse it either with an XML parser or with a JSON parser, or it is even better to use matching to match the response to a Java object and use it elsewhere in your application.
The Java-JSON mapping libraries are discussed here ( screen capture here ).
You can use JAXB to display XML-Java: https://jaxb.dev.java.net/tutorial/
An XML converter maps an XML document to a Java object.
For example, if the response is from the web service you are using:
<SampleResponse> <firstName>James</firstName> <lastName>Gosling</lastName> </SampleResponse>
An XML converter can convert it to an instance of the following class:
public class SampleResponse { private String firstName; private String lastName;
Thus:
SampleResponse myResponseObj = mapper.fromXML(xmlRespnse);
JSON manipulators work in a similar way.
Behrang
source share