API & Authentication

SOAP API Setup & Deployment Guide

Understand SOAP, WSDL and XML envelopes, call an existing SOAP service, build a small one in Node.js and deploy it securely.

Updated Official documentation ↗

1. Introduction & use cases

SOAP (Simple Object Access Protocol) is an XML-based messaging protocol for web services. Every request and response is an XML envelope, and the service is described by a WSDL file – a machine-readable contract listing operations, message types and the endpoint URL. Clients can be generated from the WSDL automatically.

SOAP is older and more verbose than REST, but it is still common in banking, payment gateways, insurance, telecom, government and ERP integrations because of its strict contracts and standards such as WS-Security.

Where it is used

  • Bank, payment and insurance integrations
  • Government and enterprise (ERP, SAP) services
  • Legacy systems that expose only WSDL interfaces
  • Strictly typed B2B contracts

2. Prerequisites

You needVersion / notes
Node.jsCurrent LTS release
Python 3 (optional)For the zeep client example
SoapUI (optional)GUI to load a WSDL and send test requests
BasicsXML and HTTP

3. Local setup

  1. 1Know the message format

    A SOAP 1.1 request is an HTTP POST with an XML envelope and a SOAPAction header.

    XML
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:tns="http://example.com/calculator">
      <soap:Header/>
      <soap:Body>
        <tns:AddRequest>
          <tns:a>2</tns:a>
          <tns:b>3</tns:b>
        </tns:AddRequest>
      </soap:Body>
    </soap:Envelope>
  2. 2Create the project

    The soap package can both serve and call SOAP services.

    BASH
    mkdir soap-demo && cd soap-demo
    npm init -y && npm pkg set type=module
    npm install soap

4. Create & run a project

  1. 1Write the WSDL contract

    Describes one operation Add(a, b) → result (document/literal style).

    calculator.wsdl
    <definitions name="Calculator" targetNamespace="http://example.com/calculator"
      xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:tns="http://example.com/calculator" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <types>
        <xsd:schema targetNamespace="http://example.com/calculator" elementFormDefault="qualified">
          <xsd:element name="AddRequest"><xsd:complexType><xsd:sequence>
            <xsd:element name="a" type="xsd:int"/><xsd:element name="b" type="xsd:int"/>
          </xsd:sequence></xsd:complexType></xsd:element>
          <xsd:element name="AddResponse"><xsd:complexType><xsd:sequence>
            <xsd:element name="result" type="xsd:int"/>
          </xsd:sequence></xsd:complexType></xsd:element>
        </xsd:schema>
      </types>
      <message name="AddInput"><part name="parameters" element="tns:AddRequest"/></message>
      <message name="AddOutput"><part name="parameters" element="tns:AddResponse"/></message>
      <portType name="CalculatorPortType">
        <operation name="Add"><input message="tns:AddInput"/><output message="tns:AddOutput"/></operation>
      </portType>
      <binding name="CalculatorBinding" type="tns:CalculatorPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="Add">
          <soap:operation soapAction="http://example.com/calculator/Add"/>
          <input><soap:body use="literal"/></input><output><soap:body use="literal"/></output>
        </operation>
      </binding>
      <service name="CalculatorService">
        <port name="CalculatorPort" binding="tns:CalculatorBinding">
          <soap:address location="http://localhost:8001/calculator"/>
        </port>
      </service>
    </definitions>
  2. 2Implement the service

    The object structure must match the WSDL names: service → port → operation.

    server.js
    import http from 'node:http';
    import { readFileSync } from 'node:fs';
    import soap from 'soap';
    
    const wsdl = readFileSync('./calculator.wsdl', 'utf8');
    const service = {
      CalculatorService: {
        CalculatorPort: {
          Add({ a, b }) {
            return { result: Number(a) + Number(b) };
          },
        },
      },
    };
    
    const server = http.createServer((req, res) => { res.statusCode = 404; res.end(); });
    server.listen(8001, () => {
      soap.listen(server, '/calculator', service, wsdl);
      console.log('WSDL: http://localhost:8001/calculator?wsdl');
    });
  3. 3Call it from a client

    The client reads the WSDL and creates methods automatically (AddAsync).

    client.js
    import soap from 'soap';
    const client = await soap.createClientAsync('http://localhost:8001/calculator?wsdl');
    const [result] = await client.AddAsync({ a: 2, b: 3 });
    console.log(result); // { result: 5 }
  4. 4Call it from Python

    Any language with a SOAP library can use the same WSDL. Install zeep with pip install zeep.

    client.py
    from zeep import Client
    
    client = Client('http://localhost:8001/calculator?wsdl')
    print(client.service.Add(a=2, b=3))
  5. 5Or call it with curl

    Save the envelope from section 3 as request.xml and post it with the SOAPAction header.

    BASH
    curl -X POST http://localhost:8001/calculator \
      -H 'Content-Type: text/xml; charset=utf-8' \
      -H 'SOAPAction: "http://example.com/calculator/Add"' \
      --data @request.xml

✅ When it works you should see output like Figure 1.

5. Development configuration

Environment variables

.env
PORT=8001
PUBLIC_URL=https://soap.example.com
PARTNER_WSDL_URL=https://partner.example.com/service?wsdl

Key dependencies

Package / toolUsed for
soap (node-soap)SOAP server and client for Node.js
zeepPython SOAP client
SoapUI / PostmanManual testing from a WSDL
WS-SecuritySigning/encryption standard used by many enterprise services

Folder structure

project structure
soap-demo/
├── calculator.wsdl   # the contract
├── server.js
├── client.js
└── request.xml       # sample envelope

Essential commands

CommandWhat it does
curl URL?wsdlDownload a service’s WSDL
node server.jsStart the SOAP service
node client.jsCall it
xmllint --noout file.wsdlCheck the XML is well-formed

6. Production deployment

Server & hosting requirements

RequirementRecommendation
ServerUbuntu VPS or container
HTTPSRequired – most partners refuse plain HTTP
Correct endpointWSDL soap:address must show the public HTTPS URL
SecurityIP allow-lists, mutual TLS or WS-Security as agreed with partners

Deployment steps

  1. 1Update the address in the WSDL

    Clients use the soap:address location from the WSDL, so set it to the public URL before deploying.

    XML
    <soap:address location="https://soap.example.com/calculator"/>
  2. 2Prepare an Ubuntu server

    Create a VPS (AWS EC2, DigitalOcean, Hostinger VPS, Linode …) with Ubuntu 24.04 LTS, at least 1 vCPU and 1–2 GB RAM. Log in with SSH, update the system and create a non-root user for the app.

    BASH
    ssh root@YOUR_SERVER_IP
    apt update && apt upgrade -y
    adduser deploy
    usermod -aG sudo deploy
    # copy your SSH key to the new user, then log in as deploy
    rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
    exit
    ssh deploy@YOUR_SERVER_IP
  3. 3Install Node.js on the server

    Install the current LTS release with nvm (or the NodeSource packages). Use the same major version as on your computer.

    BASH
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
    source ~/.bashrc
    nvm install --lts
    node -v && npm -v
  4. 4Get the code and build it

    Clone the repository on the server (or upload a build artifact from CI). Install exact dependency versions with npm ci and build.

    BASH
    git clone https://github.com/you/your-app.git /var/www/soap-demo
    cd /var/www/soap-demo
    npm ci --omit=dev
    nano .env   # production values
  5. 5Keep the app running with PM2

    PM2 restarts the app if it crashes and starts it again after a server reboot. pm2 startup prints one command – run it with sudo, then pm2 save.

    BASH
    sudo npm install -g pm2
    pm2 start server.js --name soap-demo
    pm2 startup          # run the command it prints
    pm2 save
    pm2 logs soap-demo        # live logs
    pm2 restart soap-demo     # after each deploy
  6. 6Install Nginx as a reverse proxy

    Nginx receives requests on ports 80/443 and forwards them to your app on 127.0.0.1:8001. Replace example.com with your domain.

    /etc/nginx/sites-available/example.com
    server {
        listen 80;
        server_name example.com www.example.com;
    
        location / {
            proxy_pass http://127.0.0.1:8001;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
  7. 7Enable the site and reload Nginx

    Link the config into sites-enabled, test it and reload. nginx -t must say syntax is ok before you reload.

    BASH
    sudo apt install -y nginx
    sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl reload nginx
  8. 8Open only the ports you need

    Allow SSH, HTTP and HTTPS through the firewall. Application ports (3000, 8000 …) stay closed to the internet – Nginx forwards traffic to them.

    BASH
    sudo ufw allow OpenSSH
    sudo ufw allow 'Nginx Full'   # ports 80 and 443 (after installing Nginx)
    sudo ufw enable
    sudo ufw status
  9. 9Point your domain to the server

    In your domain registrar's DNS panel add an A record for @ (and www) with the server's public IP address. DNS changes usually appear within minutes but can take up to 24–48 hours. Check with dig or an online DNS checker.

    OUTPUT
    # Type  Name  Value              TTL
    # A     @     203.0.113.10       3600
    # A     www   203.0.113.10       3600
    dig +short example.com
  10. 10Add free HTTPS with Let’s Encrypt

    Certbot gets a free SSL certificate, adds it to the Nginx config and redirects HTTP to HTTPS. Certificates renew automatically (a systemd timer runs twice a day); test renewal once with --dry-run.

    BASH
    sudo apt install -y certbot python3-certbot-nginx
    sudo certbot --nginx -d example.com -d www.example.com
    sudo certbot renew --dry-run

🗺 The whole path from your code to the live site is drawn in the deployment diagram.

7. Images & screenshots

Illustrations drawn for this guide from the commands above. Product dashboards change often, so for screens such as cloud consoles follow the step text and the official documentation.

terminal$ node server.jsWSDL: http://localhost:8001/calculator?wsdl$ node client.js{ result: 5 }$ python -c "...zeep... Add(a=2, b=3)"5
Figure 1: terminal output of the sample SOAP API project (section 4).
1WSDL contract2Node soap service3PM2 :80014Nginx + HTTPS5Partner clients
Figure 2: production deployment flow (section 6).
soap-demo/├── calculator.wsdl # the contract├── server.js├── client.js└── request.xml # sample envelope
Figure 3: project folder structure (section 5).

8. Common errors & solutions

SOAP-ENV:Client … Cannot find operation / wrong SOAPAction

The SOAPAction header or element names do not match the WSDL. Generate the request from the WSDL (SoapUI) and compare.

Namespace errors (Unexpected element)

Elements must use the exact targetNamespace from the WSDL. Check prefixes in the envelope.

415 Unsupported Media Type

SOAP 1.1 uses text/xml; SOAP 1.2 uses application/soap+xml. Send the right one.

Works locally, clients call localhost in production

The WSDL still contains http://localhost. Update soap:address to the public URL.

SSL handshake errors with a bank/partner

They may require TLS 1.2+, a client certificate (mutual TLS) or an IP allow-list. Ask for their connection checklist.

Best practices

  • Treat the WSDL as a versioned contract – never change it silently.
  • Log request/response envelopes (with sensitive fields masked) for support.
  • Set timeouts and retries on clients.
  • Prefer REST/JSON for new public APIs; use SOAP where partners require it.