a simple python/flask rest api hosted on nginx unit for proxying/transforming a rest request to an internal soap interface
adjust the url of the wsdl file in the Dockerfile (or later using the environment variable SOAP_URL):
# The url is just an example
SOAP_URL=http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
Next build the docker image:
docker build -t rest-to-soap-unit php/
docker build -t rest-to-soap-unit-helper python/
To run the docker container:
docker run --name rest-to-soap-unit -d -p 127.0.0.1:8080:8000 -e SOAP_URL=http://www.thomas-bayer.com/axis2/services/BLZService?wsdl rest-to-soap-unit
docker run --name rest-to-soap-unit-helper -d -p 127.0.0.1:9090:8000 -e SOAP_URL=http://www.thomas-bayer.com/axis2/services/BLZService?wsdl rest-to-soap-unit-helper
There are also systemd unit files included, which can be used to control the containers using systemd There will be created a docker network to run the containers into, to be able to e.g. put a reverse proxy before and then combine each individual rest-to-soap-unit to one api The containers will be controlled using the environment file, which should be created at
/etc/rest-to-soap-unit/<systemd service alias>.env
/etc/rest-to-soap-unit/service.env
and
/etc/rest-to-soa-unit/<systemd service alias>-helper.env
e.g. /etc/rest-to-soap-unit/service-helper.env
you can then control the service using:
systemctl start rest-to-soap-unit@service
systemctl start rest-to-soap-unit-helper@service
To use the app, execute a rest request to the mapped port 8080 on localhost: e.g. when using the default wsdl (public soap service for getting details about a german bank by providing the bank code or blz):
curl -X POST -d "50010060" http://localhost:8080/api/getBank
the result should be:
{
"bezeichnung": "Postbank",
"bic": "PBNKDEFFXXX",
"ort": "Frankfurt am Main",
"plz": "60288"
}
version: '3'
services:
rest-to-soap-unit:
build: php/
image: rest-to-soap-unit:latest
ports:
- "127.0.0.1:8080:8000" # Map port 8000 of docker container to 8080 on localhost
environment:
- SOAP_URL=http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
rest-to-soap-unit-helper:
build: python/
image: rest-to-soap-unit-helper:latest
ports
- "127.0.0.1:9090:8000" # Map port 8000 of docker container to 9090 on localhost
environment:
- SOAP_URL=http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
The swagger-ui can be accessed on the /doc endpoint so e.g. open http://127.0.0.1:9090/doc in the browser and the swagger-ui will open
The swagger-/openapi-configuration file can be retrieved on the /help endpoint so e.g. open http://127.0.0.1:9090/help in the browser and the swagger-configuration file will load
Because of a bug in zeep I rewrote the rest-to-soap-unit in php. The workaround currently is to have two containers, one for the proxy from rest to soap and one to be able to autogenerate an openapi specification. For now, the python container is generating the openapi specification and the php container is handling the proxy traffic.