This project demonstrates a simple SOAP API implementation using Node.js with a web client.
sequenceDiagram
participant Client as Browser Client
participant Server as Node.js SOAP Server
Client->>Server: HTTP POST /hello (SOAP Request)
Note over Client,Server: Content-Type: text/xml<br/>SOAPAction: Hello
Server->>Server: Parse SOAP Envelope
Server->>Server: Execute Hello Service
Server-->>Client: SOAP Response (XML)
Note over Client,Server: HTTP 200 OK<br/>greeting: Hello, [name]!
Client->>Server: GET /hello?wsdl
Server-->>Client: WSDL Document (XML)
- HTTP Server: Creates a basic Node.js HTTP server that listens on port 8000
- SOAP Service: The
soaplibrary attaches a SOAP service to the/helloendpoint - WSDL: The Web Services Description Language (WSDL) defines the service contract - what operations are available and their input/output formats
- Service Implementation: The
Hellofunction receives thenameparameter and returns a greeting object
- SOAP Envelope: The browser constructs a SOAP XML envelope with the user's input
- HTTP POST: Sends the XML to
http://localhost:8000/hellowith headers:Content-Type: text/xml- identifies the body as XMLSOAPAction: Hello- specifies which operation to invoke
- Response Parsing: The browser parses the XML response and extracts the
greetingelement
- Client builds XML request → 2. HTTP POST to server → 3. Server parses XML → 4. Server executes service logic → 5. Server returns XML response → 6. Client displays result
- SOAP Server: Simple Node.js SOAP service with one operation
- Operation:
Hello- returns a greeting message - WSDL: Web Services Description Language document
- Web Client: Basic HTML client to test the SOAP API
pnpm installpnpm start- Client UI: http://localhost:8000/
- SOAP Endpoint: http://localhost:8000/hello
- WSDL: http://localhost:8000/hello?wsdl
| Operation | Parameters | Description |
|---|---|---|
Hello |
name (string) |
Returns a greeting message |
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://example.com/hello">
<soap:Body>
<tns:HelloRequest>
<name>World</name>
</tns:HelloRequest>
</soap:Body>
</soap:Envelope><?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloResponse>
<greeting>Hello, World!</greeting>
</HelloResponse>
</soap:Body>
</soap:Envelope>