More and more users access the internet and rely on numerous applications and protocols for communication between web browser and web server. As the internet has evolved, the capabilities of HTTP have reached their limits. For interprocess communication between applications over the internet in particular, HTTP alone no longer provides a sufficient technical basis. The limited number of ports for RPC communication, distributed object structures, and the ever-increasing use of firewalls to protect a company’s own infrastructure confront developers with major problems. SOAP (Simple Object Access Protocol), a communication protocol that is no longer entirely new, offers a professional solution.
SOAP is primarily a specialized protocol for exchanging data between applications. The protocol structure is based on the markup language XML (Extensible Markup Language) and allows much more flexible message handling than HTTP and RPC as standalone solutions. Only the right combination of these protocols enables efficient and reliable communication on the internet that meets today’s technical requirements. The SOAP messaging protocol rests on three essential pillars that make this kind of messaging practical in the first place.
The Components of SOAP
The term "envelope" describes, at the top level, the content and use of a SOAP message. In addition, a set of encoding rules is used to "package" and apply the various data types and instances in a message. The third pillar covers the options for embedding RPCs in a SOAP message in order to process requests and the corresponding result messages. SOAP can work with a large number of existing protocols and can therefore be combined with them.
All data types used in SOAP are based primarily on the XML specification. A distinction is made between simple and compound data types. Simple data types include integers, floating-point numbers, and strings. Compound data types include structures, records, and arrays. The exact declarations of all possible data types, including simple types, strings, enumeration objects, and arrays, can be found in the W3C specification "XML Schema Part 2" (https://www.w3.org/TR/xmlschema-2/).
The SOAP Message in Detail
The following source code fragment shows the basic structure of a SOAP message. In the source code, the request GetLastTradePrice is sent to a server to ask for the current trade price of a product. The request uses a string with a ticker symbol and receives a float value with the recorded trade price in response. Alongside the "normal" HTTP header, the XML notation in the HTTP body represents the actual SOAP message in the envelope element as a self-contained request block.
POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml;
charset="utf-8"
Content-Length: nnnn
SOAPAction: "Some-URI"
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetLastTradePrice xmlns:m="Some-URI">
<symbol>DIS</symbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>The first element of this XML message is the SOAP envelope. It is followed by the namespace of the envelope, which effectively serves as a version identifier. No version numbers are used here, however. Assigning the namespace URI is sufficient for qualification. The next attribute refers to the encoding rules that are used to encode the message that follows. Here, too, the namespace is given in the form of a URI, which satisfies the requirement.
Next comes the actual body block, which contains the encoding of our price request. The body element encapsulates the actual message in the form of RPC calls or fault reports. In our example, we send an RPC to the server, which is expected to fill in the requested trade price and send it back. The closing tags turn the XML block into a consistent and valid unit.
A possible response to our request could be structured by the server as follows and displayed accordingly on the client. We refer to the individual elements of the request to make the results easier to interpret.
HTTP/1.1 200 OK
Content-Type: text/xml;
charset="utf-8"
Content-Length: nnnn
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetLastTradePriceResponse xmlns:m="Some-URI">
<Price>34.5</Price>
</m:GetLastTradePriceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>As this small example shows, we use SOAP messages that are wrapped in an XML envelope (referred to here as the SOAP envelope) and ultimately send them over HTTP. The only point to note here is that the correct media type must be specified in the HTTP header. When integrating SOAP messages, it should generally have the value text/xml.
SOAP Messages and Firewalls
Distributed object protocols have proven particularly effective on the intranet and are therefore used frequently there. Carrying these object protocols over to the open internet, by contrast, is problematic. A server that is connected to the internet can in principle be activated and opened from any client. For this reason, many companies and organizations place firewalls between the intranet and the connection to the internet to reduce potential security risks. Yet these very firewalls cause considerable problems for interprocess communication between applications on and from the internet.
On a TCP/IP network, every transfer protocol in use relies on a specific port number for access to the information. HTTP, for example, uses the standard port number 80, whereas FTP requires port 21. Firewalls make it possible to reject a request to a specific port under predefined conditions. The sticking point is the behavior of distributed object protocols. They generally do not use fixed port assignments and can even occupy several ports virtually for the transfer of a single request in order to complete their tasks. This behavior is exactly where the object model fails when a firewall is in place.
A primary goal in the implementation of SOAP messages was smooth integration into existing structures such as HTTP protocols, proxies, firewalls, and all other relevant aspects. SOAP can combine the SSL protocol (Secure Sockets Layer) as the security structure, HTTP as the transport protocol, and SOAP envelopes as the message medium. The whole package is then "simply" given a normal HTTP header and sent. When such a message packet reaches a firewall, it uses port 80, which is normally open for HTTP requests, and therefore passes the firewall without further obstacles. SOAP also supports signing and encrypting elements, which we describe in detail in a separate article, SOAP Signing and Encryption.
Conclusion
Sometimes the solutions needed for internet communication are relatively simple and can be achieved with existing implementations such as XML and SOAP. The sensible combination of existing structures and new message protocols, using the XML markup language, illustrates the potential of what is technologically possible. Once again, the flexible SOAP implementation (https://www.w3.org/TR/soap12-part1/) shows how effectively the long-established XML can be applied. The development of markup languages derived from XML to date is remarkable.
One interesting further development of SOAP, for example, adds a mechanism for sending binary data as attachments to SOAP messages. Another development is DIME (Direct Internet Message Encapsulation), which is closely modeled on the well-known MIME and offers specific advantages for SOAP attachments. RPCs (remote procedure calls) also play a very important role in SOAP and are modeled in the SOAP body by default. Alongside the more recent REST, SOAP continues to have its place and is the preferred choice in certain use cases.