Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure REST/HTTP-style APIs at any scale. Unfortunately, there’s no clear out-of-the box support for SOAP APIs. For enterprise that still lean heavily on SOAP and want to expose their webservices via Amazon API Gateway, this small recipe might help push things in the right direction.
Configure the API
- Enter the Amazon API Gateway console and create a new API. Then, create a POST method.
- In the Method Request configuration page, create the following three http-headers: Accept, Content-Type and SOAPAction (note that not all SOAP webservices require a SOAPAction).
- In the Integration Request config page set:
- Integration type: HTTP
- Method: POST
- Endpoint URL: SOAP endpoint of the SOAP service you’re exposing. For this recipe, I’m using the free GetCountries webservice from webservicex.net which simply returns a list of countries.
- Content-handling: passthrough
- Body Mapping Templates: ‘When there are no templates defined (recommended)’
- Content-handling: Passthrough
- Response Body for 200, set response model content-type to: text/xml
Test using Amazon API Gateway Method Tester
With the Method Test tool it’s very easy to test your configuration. Just click on the Test link. In the next page, put in the correct header values. To get the correct values quickly, use a tool like SoapUI and check out the raw message. In here, you’ll find the header values of the SOAP-requestmessage. Put in a request body string and fire your request. A Response Body will return in the right textfield.
Deploy the API
When you’re done testing, deploy your API by clicking on ‘Deploy API’. A public API endpoint will be returned. You can use the SoapUI project that you used during testing and replace the SOAP endpoint with the API Gateway endpoint. When everything’s configured OK, a proper SOAP response will return.
** Please note that no production testing has been performed by me using below config so you might want to do your own feasibility study first! **