Skip to main content

soap

The soap plugin converts JSON requests into SOAP operations defined by a Web Services Description Language (WSDL) document. It also converts the SOAP response into JSON before returning it to the client.

The plugin delegates WSDL parsing and protocol conversion to soap-proxy, which must be reachable from every gateway instance.

Examples​

Prerequisites​

  • For the Admin API tabs, set the Dashboard address and gateway group, then enter a Dashboard token:

    export API7_ADMIN_URL="https://localhost:7443"
    export API7_GATEWAY_GROUP_ID="default"
    printf "Dashboard token: "
    read -rs API7_ADMIN_KEY && export API7_ADMIN_KEY && echo

    The -k flag in these examples accepts the local Dashboard's self-signed certificate. Remove it when using a certificate trusted by the client.

  • For the ADC tabs, select the api7ee backend and configure the corresponding Dashboard address, token, and gateway group.

The following workflow starts the SOAP proxy, configures its gateway endpoint, and invokes a public SOAP operation through API7 Gateway.

Set Up SOAP Proxy​

Choose the setup that matches the gateway deployment.

Set GATEWAY_CONTAINER to the running API7 Gateway container. Create a dedicated network and connect the gateway to it:

export GATEWAY_CONTAINER=replace-with-gateway-container-name

docker network create gateway-soap-net
docker network connect gateway-soap-net "$GATEWAY_CONTAINER"

Start the SOAP proxy on the shared network with the image used by the current API7 Gateway chart:

docker run -d \
--name soap-proxy \
--network gateway-soap-net \
api7/soap-proxy:1.0.0

Add the SOAP proxy endpoint to the persistent config.yaml used by the gateway deployment:

config.yaml
plugin_attr:
soap:
endpoint: http://soap-proxy:5000
timeout: 3000

Reload the gateway after updating its configuration source:

docker exec "$GATEWAY_CONTAINER" apisix reload

Invoke a SOAP Operation​

The following example demonstrates how to map POST /SayHello to the SayHello operation in the WSDL document.

Create the route:

Create a service for the route. It needs no upstream, because the plugin sends the request to soap-proxy:

curl -k "${API7_ADMIN_URL}/apisix/admin/services/soap-service?gateway_group_id=${API7_GATEWAY_GROUP_ID}" -X PUT \
-H "X-API-KEY: ${API7_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "soap-service"
}'

Create the route in the service:

curl -k "${API7_ADMIN_URL}/apisix/admin/routes/soap-hello?gateway_group_id=${API7_GATEWAY_GROUP_ID}" -X PUT \
-H "X-API-KEY: ${API7_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "soap-hello",
"service_id": "soap-service",
"paths": ["/SayHello"],
"methods": ["POST"],
"plugins": {
"soap": {
"wsdl_url": "https://apps.learnwebservices.com/services/hello?wsdl"
}
}
}'

The request path identifies the WSDL operation, and wsdl_url identifies the service contract and upstream SOAP endpoint.

The ADC and Gateway API tabs include a conventional backend. When the plugin handles the request itself, the backend is not contacted. Verify the plugin-specific result below; a backend response alone does not confirm that the plugin ran.

Send a JSON request to the route:

curl -i "http://127.0.0.1:9080/SayHello" \
-H "Content-Type: application/json" \
-d '{"Name": "John Doe"}'

API7 Gateway should return HTTP/1.1 200 OK with the following response body:

"Hello John Doe!"