JSON Example 1: GET Request, JSON Response
In this example, a consumer sends a GET request to get a native JSON service. Mediator will send the response to the consumer in the requested JSON format (as indicated by the "output=json" parameter in the query).
The request looks like this:
http://localhost:5555/ws/YahooVS/search?query=wsdl20&output=json
and because this is a GET request, the Content-Type defaults to application/x-www-form-urlencoded.
Note: | For GET or DELETE requests for REST services, it is not necessary to specify the Content-Type in the request; Mediator will default to application/x-www-form-urlencoded for GET or DELETE requests. |
The run-time processing will be as follows:
Consumer Sends | Mediator Sends Request to Provider | Mediator Receives Response from Provider | Mediator Sends Response to Consumer | Requirement for Bridging |
GET | GET | JSON | JSON | Request Processing step bridging |
Since the request is a GET (i.e., of Content-Type application/x-www-form-urlencoded), but Mediator expects to receive a JSON stream from the provider, you must send the BUILDER_TYPE application/json to the native provider. To do this, write and invoke a webMethods IS service in the virtual service’s Invoke webMethods IS Service action. The IS service should include the following predefined context variable set to this value:
Context Variable | Value |
BUILDER_TYPE | application/json |