We will use a SOAP service to use SOAP in the WSO2 API Manager 2.6. We will add a new API that points to a SOAP Backend. We will first use the passthrough option.
After starting the WSO2 API Manager 2.6, log in to the API Publisher and create a new API, using the WSDL mentioned above.
After clicking Start Creating and fill in the details:
Name | Factbook_Pass_Through |
Context | /factbook |
Version | 1.0 |
Thumbnail image | Download the image |
Click on implement to go to the second tab and fill in the following details:
Endpoint | HTTP/SOAP Endpoint |
Production | http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso |
Click on Manage and fill in these details:
Make this the default version: | unchecked |
No default version defined for the current API | |
Transports: | select HTTPS HTTP |
Response Caching: | |
Authorization Header: | |
Throttling Settings | |
Maximum Backend Throughput: | Unlimited |
Subscription Tiers: | Unlimited : Allows unlimited requests |
Advanced Throttling Policies: | Apply to API / Unlimited |
Leave the Resources as configured automatically.
Press Save & Publish to Publish the API.
See the API in the Publisher.
API REST
Letās create a second version, this time we will create the REST APIs.
Name | Factbook_Pass_Through |
Context | /factbook |
Version | 1.0 |
Thumbnail image | Download the image |
See the API Definition that was created based on the WSDL.
Press Implement to go to the next tab.
Fill in the details the same as before.
Endpoint | HTTP/SOAP Endpoint |
Production | http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso |
See that thereās a mapping defined.
Clicking on language shows the translation from REST TO SOAP.
Press on Manage Button.
Fill in these details.
Make this the default version: | unchecked |
No default version defined for the current API | |
Transports: | select HTTPS HTTP |
Response Caching: | |
Authorization Header: | |
Throttling Settings | |
Maximum Backend Throughput: | Unlimited |
Subscription Tiers: | Unlimited : Allows unlimited requests |
Advanced Throttling Policies: | Apply to API / Unlimited |
See that thereās a list of resources defined.
Press Save & Publish.
Go to the store and see the two APIs.
Sign in using admin/admin credentials and create a new application called CIA. Generate the client key / secret pair.
Subscribe to the Pass_Through API using the CIA application and Go to the API Console.
Click Try it and fill in this SOAP Message:
<soapenv:Envelope xmlns_soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns_web="http://www.oorsprong.org/websamples.countryinfo">
<soapenv:Header/>
<soapenv:Body>
<web:CapitalCity>
<web:sCountryISOCode>NLD</web:sCountryISOCode>
</web:CapitalCity>
</soapenv:Body>
</soapenv:Envelope>
NOTE: you can create this by using SoapUI and the wsdl on a new SOAP Project.
And SOAPAction sCountryISOCode
If you do not see a response copy the response URL https://192.168.122.1:8243/factbook/1.0/* to the browser and copy it in the URL bar. Press enter. This will trigger the security exception and add an exception.
This is the response, giving the capital city of The Netherlands.
<soap:Envelope>
<soap:Body>
<m:CapitalCityResponse>
<m:CapitalCityResult>Amsterdam</m:CapitalCityResult>
</m:CapitalCityResponse>
</soap:Body>
</soap:Envelope>
Also subscribe to the Factbook_API and test the REST API /capitalCity with a sCountryISOCode NLD.
The JSON response is:
{
"CapitalCityResponse": {
"CapitalCityResult": "Amsterdam"
}
}
You now have two APIās that talk to a SOAP backend service, one that simply passes the message and another one that has a REST frontend to the SOAP backend.