How to add for format=json in oracle weblogic server
I have installed oracle weblogic server 11g.Implemented开发者_运维百科 RESTFul but as per document when I place there format=json. It should works but it is not working.
Can you please let me know, how to resolve response as json.
you can get a working example of how to do this here: https://www.samplecode.oracle.com/sf/projects/oracle-parcel-svc/ and we have a webcast series that covers JAX-RS on WLS in Session 4 at this link:http://www.oracle.com/technetwork/middleware/weblogic/learnmore/weblogic-javaee6-webcasts-358613.html
When you configure your method that you want to return JSON from you have to specify that it produces JSON. Here's one way to do it:
@GET
@Path("{id}.json")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Parcel getParcelById_json(@PathParam("id") int id)
{
return getParcelById(id);
}
You also need to put the right HTTP headers in the client in order to specify that it expects a JSON response. Some test clients like SOAP-UI auto-convert JSON to XML such that you can do an XPATH on it, even though the actual transmission of data is JSON.
精彩评论