SOAP Proxy
SOAP is an old and complex protocol with many specifications and extensions, making it difficult to support it directly and ensure that it is implemented correctly.
We use an external process to forward and transform requests to implement the REST to SOAP process, where the client sends a standard HTTP JSON request to the gateway, and the gateway dynamically transforms the request into SOAP XML to send to the SOAP service and vice versa.
Prepare environment
The docker-compose
file is under here.
Since this feature has not yet been integrated into API7 EE, APISIX is used here for demonstration purposes.
cd docker
docker compose up -d
Configure the SOAP proxy plugin
This demo is out-of-the-box and uses https://github.com/spring-guides/gs-producing-web-service as the SOAP service for the demo.
We actually configured the soap-demo
plugin, which is configured as follows:
{
"wsdl_url": "http://soap-server:8080/ws/countries.wsdl"
}
In the minimal case, only the service WSDL address needs to be configured.
Test
Original SOAP service
curl 127.0.0.1:19081/ws \
-H 'Content-Type: text/xml' \
--data '<?xml version='\''1.0'\'' encoding='\''utf-8'\''?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<ns0:getCountryRequest xmlns:ns0="http://spring.io/guides/gs-producing-web-service">
<ns0:name>Spain</ns0:name>
</ns0:getCountryRequest>
</soap-env:Body>
</soap-env:Envelope>'
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:getCountryResponse xmlns:ns2="http://spring.io/guides/gs-producing-web-service">
<ns2:country>
<ns2:name>Spain</ns2:name>
<ns2:population>46704314</ns2:population>
<ns2:capital>Madrid</ns2:capital>
<ns2:currency>EUR</ns2:currency>
</ns2:country>
</ns2:getCountryResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
APISIX SOAP2REST
curl 127.0.0.1:19080/getCountry -s -H 'Content-Type: application/json' --data '{"name": "Spain"}' | jq
{
"capital": "Madrid",
"currency": "EUR",
"name": "Spain",
"population": 46704314
}