Node.js code for Make SOAP Request Example
This Node.js code snippet was generated automatically for the Make SOAP Request example.
<< Back to the Make SOAP Request exampleWhat is SOAP?
SOAP is an Object Access Protocol that Microsoft developed to replace older technologies such as DCOM (Distributed Component Object Model) and General CORBA (Object Request Broker Architecture). DCOM and CORBA are inferior because they rely on binary messages, while SOAP uses XML and works better over the Internet. SOAP relies exclusively on XML and, together with schemas, defines a strongly typed messaging structure. The main idea behind SOAP is that programs written in different programming languages and platforms can easily exchange data.
SOAP Example
<?xml version='1.0' Encoding='UTF-8' ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<m:reservation xmlns:m="https://www.website.com/reservation" env:role="http://www.w3.org/2003/05/soap-envelope/role/next">
<m:reference>uuid:11111-22222-333333-444444-555555</m:reference>
<m:dateAndTime>2020-01-01</m:dateAndTime>
</m:reservation>
<n:passenger xmlns:n="https://www.website.com/employees" env:role="http://www.w3.org/2003/05/soap-envelope/role/next">
<n:name>John Smith</n:name>
</n:passenger>
</env:Header>
<env:Body>
<p:itinerary xmlns:p="https://www.website.com/reservation/travel">
<p:departure>
<p:departing>New York</p:departing>
<p:arriving>Los Angeles</p:arriving>
<p:departureDate>2020-01-01</p:departureDate>
</p:departure>
</p:itinerary>
</env:Body>
</env:Envelope>
What is XML?
XML (eXtensible Markup Language) that provides structured information: data, documents, configuration, and more. XML was designed to be a language with a simple formal syntax to make it easy for both humans and programs to create and manage documents for use on the Internet. XML is called extensible because it does not capture the markup used in documents: you can generate markup according to the needs of a specific area, limited only by the rules of XML syntax.
XML Example
<Request>
<Login>
login
</Login>
<Password>
password
</Password>
</Request>
How to send a SOAP Request?
An example of sending a SOAP request to the SOAP API endpoint:
SOAP Request Example
POST /xml/tempconvert.asmx HTTP/1.1
Host: www.website.com
Content-Type: application/soap+xml
Content-Length: 349
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<GetUserBalance xmlns="https://www.website.com/xml/">
<UserId>75</UserId>
</GetUserBalance>
</soap:Body>
</soap:Envelope>
SOAP response from server:
SOAP Response Example
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 413
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetUserBalanceResponse xmlns="https://www.website.com/xml/">
<GetUserBalanceResult>1000.00</GetUserBalanceResult>
</GetUserBalanceResponse>
</soap:Body>
</soap:Envelope>
See also