Contents
You can import a WSDL file into Policy Studio, and instead of exposing it to a client, invoke it from a policy. For example, in a SOAP to REST use case, the web service is registered in Policy Studio by importing a WSDL file into the web service repository. A REST API is then defined in Policy Studio, which calls a policy to implement the API, and in turn, this policy invokes the web service.
The steps involved in exposing a SOAP web service as a REST API are summarized as follows:
-
Virtualize the SOAP web service.
-
Define a new REST API.
-
Route all REST requests through the virtualized SOAP service.
-
Test the REST to SOAP mapping.
To expose a virtualized version of a SOAP web service on API Gateway, import a WSDL file describing the web service into the web service repository. The following figure shows importing the WSDL for a stock quote SOAP web service exposed on the URL:
http://www.webservicex.net/stockquote.asmx?WSDL

For more information on using the Import WSDL wizard, see the section called “Import a WSDL file”.
When you register a web service in Policy Studio, service handlers and policies are autogenerated. The following figure shows the generated policies for the stock quote service.

The next step is to define a REST API for a stock quote service. You can develop REST APIs in Policy Studio using the REST API development wizard. To launch the wizard, right-click the Business Services > REST API Repository node in the Policy Studio tree and select Add REST API.
Follow these steps:
-
Define a REST API called
StockQuote
and expose it on the base path/stockquote
. -
Define a REST API method called
GetStockQuote
. Set the exposure settings as follows and add an inbound parameter for the stock symbol: -
Set the routing policy to the StockQuote policy that was autogenerated when you imported the WSDL for the web service. For example:
To route REST requests through the virtualized SOAP service, perform the following sequence of tasks.
First, create a dedicated request processing policy to create the SOAP request message body to send to the SOAP service:
-
Create a request processing policy called
GetStockQuoteRequest
. -
Add a Set Message filter to the policy.
-
Enter
text/xml
as the Content-Type. -
Select From web service operation from the Populate menu and select the
GetQuote
operation from the stock quote web service. This populates the contents of the message body. -
To insert a REST API parameter for the stock symbol, right-click in the message body and select Insert > REST API parameter.
Select the
symbol
parameter from the Insert REST API Parameter dialog.This replaces the selected text with the
${params.query.symbol}
selector string:
-
-
Add a Set HTTP verb filter to the policy and enter
POST
in the HTTP Verb field. -
Add an Add HTTP header filter to the policy with the following settings:
The following figure shows the completed policy.

Next, edit the REST API method GetStockQuote
and set this policy as the request processing policy.
Next, create a response processing policy to convert the XML returned from the SOAP web service from XML to JSON format:
-
Create a response processing policy called
XML To JSON
. -
Add an XML to JSON filter to the policy. Configure it to extract the SOAP Body content first and remove any namespaces:
To test the REST to SOAP mapping, deploy the configuration on the API Gateway and send a REST request from a REST client. For example, to get a stock quote for Amazon, send a request to the URL:
http://localhost:8080/stockquote/getStockQuote?symbol=AMZN
The following is an example JSON response:
{ "GetQuoteResponse": { "GetQuoteResult": "<StockQuotes><Stock><Symbol>AMZN</Symbol> <Last>381.83</Last><Date>2/13/2015</Date><Time>4:00pm</Time> <Change>+4.66</Change><Open>378.41</Open><High>383.00</High> <Low>377.01</Low><Volume>3475069</Volume><MktCap>177.3B</MktCap> <PreviousClose>377.17</PreviousClose><PercentageChange>+1.24%</PercentageChange> <AnnRange>284.00 - 383.11</AnnRange><Earns>-0.522</Earns> <P-E>N/A</P-E><Name>Amazon.com</Name></Stock></StockQuotes>" } }