Invoking a REST-enabled SOAP API
This section explains how a consumer can invoke a RESTful SOAP API using a REST request.
SOAP Version Handling
Mediator requires the SOAP version of the native endpoint to transform the REST request it receives to a SOAP request. You must select the SOAP version to which the native SOAP API must be virtualized in CentraSite. This information is then passed on to the corresponding Mediator endpoint.
CentraSite supports the following SOAP versions:
SOAP 1.1
SOAP 1.2
SOAP Action Handling
Mediator retrieves the SOAP action information from the WSDL file for the virtual API and adds a SOAP action HTTP header to the outbound request based on the action that is invoked.
SOAP Response Handling
Mediator transforms the native service’s SOAP response to a SOAP or REST response depending on the Accept-Header set by the client. The default content-type is application/json. You can set the content-type that Mediator must use if the client does not send an Accept-Header using the Default Content Type parameter of the Request/Response Message settings.
Content-Type Conversion
Mediator supports the following content-types in a REST request to a REST-enabled SOAP service:
application/xml application/json application/json/badgerfish application/x-www-form-urlencoded text/xml multipart/form-data Mediator converts these content-types in a request to either application/soap+xml (SOAP 1.1) or text/xml (SOAP 1.2), and sends the requests to the native SOAP service. If the request does not contain a content-type header, Mediator uses the default content-type, application/json.
Example
If you have a StockQuote API, http://www.webservicex.net/stockquote.asmx?WSDL with one SOAP operation, GetQuote, the REST enpoint for the API is http://<Context-path>/StockQuoteService/GetQuote.
REST requests to the StockQuote API for different content-types are listed in the following table:
Content-Type(s) | REST Request |
application/xmltext/xml | <web:GetQuote xmlns:web="http://www.webserviceX.NET/"> <web:symbol >ABC </web:symbol></web:GetQuote> or <web:symbol xmlns:web="http://www.webserviceX.NET/">ABC </web:symbol> Note: If you do not specify the namespace in the request, Mediator adds the namespace to the request after converting the request. |
application/json | { "GetQuote" : { "symbol" : "ABC" } } or { "symbol" : "ABC" } Note: If you do not specify the namespace in the request, Mediator adds the namespace to the request after converting the request. |
application/x-www-form-urlencoded | ?symbol=ABC Note: Mediator supports URL-encoded parameters only for one level of elements. If the request has nested elements, the same cannot be supported in this format. |