Thursday, May 16, 2013

Response based on Service Types in OSB


Restful services can be implemented using either Proxy type- Any XML Service or Messaging Service types.
·         Messaging Service - to create a service that can receive messages of one data type and respond with messages of a different data type. These exchanges can be either request/response or one-way.

·         Any XML Service - to create an XML service that does not have an explicitly defined, concrete interface.
There is a difference in the way the responses are handled in each case. It’s interesting to see how the response looks like if we add a proxy layer before the existing proxies. I was implementing the Gateway approach where all existing proxies need to be plugged in into the Gateway proxy. In Gateway I am converting the response to either JSON or pass through XML based on the response format requested by the consumer.
Messaging Service response
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<![CDATA[<GetStatusResponseMsg xmlns="http://geo.com/v1.0">
 <GetStatusResponse xmlns="http://geo.com/test/v1.0">
<ResponseStatus xmlns="http://geo.com/status">PENDING</ResponseStatus>
</ GetStatusResponse >
</ GetStatusResponseMsg >]]>
</soapenv:Body>>
In case your proxy is Messaging service based then the response will be encapsulated in the CDATA tag. You will need to use fn-bea:inlinedXML($body) to fetch the XML from the response body.
Any XML Service response
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <GetStatusResponseMsg xmlns="http://geo.com/v1.0">
 <GetStatusResponse xmlns="http://geo.com/test/v1.0">
<ResponseStatus xmlns="http://geo.com/status">PENDING</ResponseStatus>
</ GetStatusResponse >
</ GetStatusResponseMsg>
</soapenv:Body>>
In case of this approach the response will be in proper XML format without any CDATA encoding.

No comments: