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 need | Version / notes |
|---|---|
| Node.js | Current LTS release |
| Python 3 (optional) | For the zeep client example |
| SoapUI (optional) | GUI to load a WSDL and send test requests |
| Basics | XML and HTTP |
3. Local setup
1Know the message format
A SOAP 1.1 request is an HTTP POST with an XML envelope and a
SOAPActionheader.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>2Create the project
The
soappackage can both serve and call SOAP services.BASHmkdir soap-demo && cd soap-demo npm init -y && npm pkg set type=module npm install soap
4. Create & run a project
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>2Implement the service
The object structure must match the WSDL names: service → port → operation.
server.jsimport 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'); });3Call it from a client
The client reads the WSDL and creates methods automatically (
AddAsync).client.jsimport 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 }4Call it from Python
Any language with a SOAP library can use the same WSDL. Install zeep with
pip install zeep.client.pyfrom zeep import Client client = Client('http://localhost:8001/calculator?wsdl') print(client.service.Add(a=2, b=3))5Or call it with curl
Save the envelope from section 3 as
request.xmland post it with the SOAPAction header.BASHcurl -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
PORT=8001
PUBLIC_URL=https://soap.example.com
PARTNER_WSDL_URL=https://partner.example.com/service?wsdlKey dependencies
| Package / tool | Used for |
|---|---|
soap (node-soap) | SOAP server and client for Node.js |
zeep | Python SOAP client |
SoapUI / Postman | Manual testing from a WSDL |
WS-Security | Signing/encryption standard used by many enterprise services |
Folder structure
soap-demo/
├── calculator.wsdl # the contract
├── server.js
├── client.js
└── request.xml # sample envelopeEssential commands
| Command | What it does |
|---|---|
curl URL?wsdl | Download a service’s WSDL |
node server.js | Start the SOAP service |
node client.js | Call it |
xmllint --noout file.wsdl | Check the XML is well-formed |
6. Production deployment
Server & hosting requirements
| Requirement | Recommendation |
|---|---|
| Server | Ubuntu VPS or container |
| HTTPS | Required – most partners refuse plain HTTP |
| Correct endpoint | WSDL soap:address must show the public HTTPS URL |
| Security | IP allow-lists, mutual TLS or WS-Security as agreed with partners |
Deployment steps
1Update the address in the WSDL
Clients use the
soap:address locationfrom the WSDL, so set it to the public URL before deploying.XML<soap:address location="https://soap.example.com/calculator"/>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.
BASHssh 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_IP3Install 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.
BASHcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash source ~/.bashrc nvm install --lts node -v && npm -v4Get the code and build it
Clone the repository on the server (or upload a build artifact from CI). Install exact dependency versions with
npm ciand build.BASHgit clone https://github.com/you/your-app.git /var/www/soap-demo cd /var/www/soap-demo npm ci --omit=dev nano .env # production values5Keep the app running with PM2
PM2 restarts the app if it crashes and starts it again after a server reboot.
pm2 startupprints one command – run it with sudo, thenpm2 save.BASHsudo 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 deploy6Install Nginx as a reverse proxy
Nginx receives requests on ports 80/443 and forwards them to your app on
127.0.0.1:8001. Replaceexample.comwith your domain./etc/nginx/sites-available/example.comserver { 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"; } }7Enable the site and reload Nginx
Link the config into
sites-enabled, test it and reload.nginx -tmust say syntax is ok before you reload.BASHsudo apt install -y nginx sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx8Open 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.
BASHsudo ufw allow OpenSSH sudo ufw allow 'Nginx Full' # ports 80 and 443 (after installing Nginx) sudo ufw enable sudo ufw status9Point your domain to the server
In your domain registrar's DNS panel add an A record for
@(andwww) with the server's public IP address. DNS changes usually appear within minutes but can take up to 24–48 hours. Check withdigor 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.com10Add 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.BASHsudo 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.
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.