Git Product home page Git Product logo

rest-to-soap-unit's Introduction

rest-to-soap-unit

a simple python/flask rest api hosted on nginx unit for proxying/transforming a rest request to an internal soap interface

Diagram

Building

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/

Usage

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

Systemd

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"
}

Usage in docker-compose

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

Swagger-UI

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

Swagger-Configuration file

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

BUG IN ZEEP

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.

rest-to-soap-unit's People

Contributors

llxp avatar marcofuchs89 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

frankmann85

rest-to-soap-unit's Issues

Error in app.js preventing the container from starting correctly

Error log:

/www/app.js:52
});
^
SyntaxError: Missing catch or finally after try
at Object.compileFunction (node:vm:355:18)
at wrapSafe (node:internal/modules/cjs/loader:1022:15)
at Module._compile (node:internal/modules/cjs/loader:1056:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
2021/08/23 07:49:55 [notice] 13#13 process 21 exited with code 1
2021/08/23 07:49:55 [warn] 17#17 failed to start application "express"
2021/08/23 07:49:55 [alert] 17#17 failed to apply new conf
/usr/local/bin/docker-entrypoint.sh: Error: HTTP response status code is '500'
{
"error": "Failed to apply new configuration."
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.