JSON Example 3: GET Request, XML Response
In this example, a consumer sends a GET request to get a native service. Mediator will send the response to the consumer in the requested XML format (as indicated by the "output=xml" parameter in the query).
The request looks like this:
http://localhost:5555/ws/YahooVS/search?query=wsdl20&output=xml
and because this is a GET request, the Content-Type defaults to application/x-www-form-urlencoded.
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 | XML | Request Processing step bridging Response 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 instruct Mediator to 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 |
Since the provider will return a JSON stream to Mediator, but the consumer expects to receive the service in XML output format, you must set the MESSAGE_TYPE to application/xml. 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 |
MESSAGE_TYPE | application/xml |