Understanding SOAP
Kenn Scribner
Mark C. Stiver
Copyright© 2000 Kenn Scribner and Mark C. Stiver
SOAP
• Simple
• Object
• Access
• Protocol
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Waves of the Internet
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Waves of the Internet
• 1st Wave: Engineering research
– Interconnecting systems at the TCP/IP level
– Network packets, addressing, routing
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Waves of the Internet
• 2nd Wave: Engineer to System
– Publishing of data (FTP)
– Remote system access (Telnet)
– Information discovery (Gopher)
– Difficult to use tools
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Waves of the Internet
• 3rd Wave: Consumer to System
– Web browsers
– Electronic Business systems (shopping carts)
– Java applets
– Presentation based
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Waves of the Internet
• 4th Wave: Application to Application (B2B)
– Services on the web
– Service advertisement/discovery
– Process integration
– Information based
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Motivations
• Heterogeneous systems must be able to
communicate
• Binary protocols don’t always work
– CORBA, DCOM, etc. don’t work well through firewalls
– Nobody can agree on a standard binary format (usually due to
platform-related issues)
– We’re dealing with many heterogeneous environments (MVS,
Unix, Windows NT, Linux, PalmOS, etc.)
– Component runtimes differ
– Security models differ (Kerberos, NTLM, OSF-DCE)
Copyright© 2000 Kenn Scribner and Mark C. Stiver
What we need...
• Standards (as usual)
• A firewall-friendly protocol
• An extensible framework
• Low cost of entry
• Loose coupling
• Platform and programming language
agnostic technology
Copyright© 2000 Kenn Scribner and Mark C. Stiver
What do we have to work with?
• XML - An extensible framework that is
easy-to-use and has a low-cost of entry
• HTTP/SMTP - Industry accepted transport
protocols that are already supported by
Enterprise servers and are friendly with
firewalls
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Enter SOAP...
Copyright© 2000 Kenn Scribner and Mark C. Stiver
What SOAP is...
• SOAP is a specification for defining...
– an encoding style that uses XML to represent
information graphs
– a standard way to move XML with HTTP
– rules for passing messages
– error (fault) definition
– a medium for performing Remote Procedure
Calls (RPC)
– one layer in a multi-layer architecture
Copyright© 2000 Kenn Scribner and Mark C. Stiver
What SOAP isn’t...
• A silver bullet
• A definition of interface semantics
• A security model
• A run-time definition
Copyright© 2000 Kenn Scribner and Mark C. Stiver
SOAP Encoding
• Envelope package
• Header/Body pattern
– Similar to how HTTP works
Header
Body
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Header
• Out-of-band information such as…
– Authentication information
– Message routes
– Logging
– Transaction flow
• Basically, any information that is disjoint
from interface methods/messages
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Body
• Interface-specific information such as…
– RPC method name and parameters
– Serialized objects (instances of types)
– Messages
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Simple Example
<Envelope>
<Header>
<transId>1234</transId>
</Header>
<Body>
<Add>
c = Add(a, b)
<a>3</a>
<b>4</b>
</Add>
</Body>
</Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
System Flow (HTTP)
<Envelope>
<Header>
<transId>1234</transId>
</Header>
<Body>
<Add>
<a>3</a>
<b>4</b>
</Add>
</Body>
</Envelope>
<Envelope>
<Header>
<transId>1234</transId>
</Header>
<Body>
<AddResponse>
<c>7</c>
</AddResponse>
</Body>
</Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
So, what’s missing?
• Avoiding ambiguity in messages
– XML Namespaces
• Describing data types
– XML Schemas
• Binding to a transport
– HTTP header fields
Copyright© 2000 Kenn Scribner and Mark C. Stiver
XML Namespaces
• Default namespace
<Book xmlns=“Some-URI”>
<Author>Tom Clancy</Author>
</Book>
• Qualifying names with prefixes
Unqualified
<b:Book xmlns:b=“Some-URI”> element
<Author>Tom Clancy</Author>
</b:Book>
URI: A string that can contains a string that is assumed unique.
URLs are one form of URI since domain names must be unique!
[Link]
Copyright© 2000 Kenn Scribner and Mark C. Stiver
XML Schemas
• Type defines…
– Hierarchies
– Structure
– Constraints (facets)
• Simple types
– Integers, strings, floats, time, etc.
• Compound types
– Arrays, structures
Copyright© 2000 Kenn Scribner and Mark C. Stiver
XML Schema Example
<?xml version="1.0"?>
<schema
targetNamespace="[Link]
xmlns="[Link]
<element name="TradePriceRequest">
<complexType>
<all>
<element name="tickerSymbol" type="string"/>
</all>
</complexType>
</element>
<element name="TradePrice">
<complexType>
<all>
<element name="price" type="float"/>
</all>
</complexType>
</element>
</schema>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Actual SOAP Request
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Add xmlns:m=“[Link]
<a xsi:type=“integer”>3</a>
<b xsi:type=“integer”>4</b>
</m:Add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Actual SOAP Request
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Add xmlns:m=“[Link]
<a xsi:type=“integer”>3</a>
<b xsi:type=“integer”>4</b>
</m:Add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Actual SOAP Response
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:AddResponse xmlns:m=“[Link]
<c xsi:type=“integer”>7</c>
</m:AddResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Actual SOAP Response
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:AddResponse xmlns:m=“[Link]
<c xsi:type=“integer”>7</c>
</m:AddResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Analyzing a Request
Scopes the message to the SOAP
<SOAP-ENV:Envelope namespace
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
...etc...
</SOAP-ENV:Envelope>
Establishes the type of encoding
that is used within the message
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Analyzing a Request
...etc...
<SOAP-ENV:Header> Qualifies transId
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body> Establishes the interface/method
<m:Add xmlns:m=“[Link]
<a xsi:type=“integer”>3</a>
<b xsi:type=“integer”>4</b>
</m:Add>
</SOAP-ENV:Body> Describes parameter types
...etc...
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Requests as RPC
• Method element immediately follows
<Body>
• Parameters are serialized in left-to-right order
• Normally, xsi:type is used to provide type
information (XML Schemas)
• Method element
<SOAP-ENV:Body>
NS qualifies entire message
<m:Add xmlns:m=“[Link]
<a xsi:type=“integer”>3</a>
<b xsi:type=“integer”>4</b>
</m:Add>
</SOAP-ENV:Body>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Analyzing a Response
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:AddResponse xmlns:m=“[Link]
<c xsi:type=“integer”>7</c>
</m:AddResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> Response typically uses method
name with “Response” appended
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Serializing Types
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Values and References
• By value - Add([in] int a, [in] int b);
<m:Add xmlns:m=“[Link]
<a xsi:type=“integer”>3</a>
<b xsi:type=“integer”>4</b>
</m:Add>
• By reference - Square([in, out] int &a);
<m:Add xmlns:m=“[Link]
<a href=“#arg” />
</m:Add>
<a id=“arg” xsi:type=“integer”>8</a>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Arrays
• Arrays
int a[3] = {1, 2, 3};
b = Add([in]a);
<m:Add xmlns:m=“[Link]
xmlns:SOAP-ENC="[Link]
<a SOAP-ENC:arrayType=“xsd:int[3]”>
<SOAP-ENC:int>1</SOAP-ENC:int>
<SOAP-ENC:int>2</SOAP-ENC:int>
<SOAP-ENC:int>3</SOAP-ENC:int>
</a>
</m:Add>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Applying SOAP to a Transport
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Binding to HTTP (Request)
POST /[Link] HTTP/1.0
Host: [Link]
Accept: text/*
Content-type: text/xml
Content-length: nnnn
SOAPAction: “[Link]
{CR}{LF}
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Add xmlns:m=“[Link]
<a xsi:type=“integer”>3</a>
<b xsi:type=“integer”>4</b>
</m:Add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Binding to HTTP (Response)
HTTP/1.0 200 OK
Content-type: text/xml
Content-length: nnnn
{CR}{LF}
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:AddResponse xmlns:m=“[Link]
<c xsi:type=“integer”>7</c>
</m:AddResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
SOAPAction
POST /[Link] HTTP/1.0 This is my intent!
Host: [Link]
Accept: text/*
Content-type: text/xml
Content-length: nnnn
SOAPAction: “[Link]
{CR}{LF}
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Header>
<t:transId xmlns:t=“[Link]
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Add xmlns:m=“[Link]
...etc...
Copyright© 2000 Kenn Scribner and Mark C. Stiver
SOAP Faults
HTTP/1.0 200 OK
Content-type: text/xml
Content-length: nnnn
{CR}{LF}
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“[Link]
SOAP-ENV:encodingStyle="[Link]
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Internal Application Error</faultstring>
<detail xmlns:f=“[Link]
<f:errorCode>794634</f:errorCode>
<f:errorMsg>Divide by zero</f:errorMsg>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Where are we?
Application Web Service
Interface Semantics Interface Semantics
SOAP
Envelope/Header/Body Envelope/Header/Body
Message Encoding Message Encoding
Transport (e.g. HTTP) Transport (e.g. HTTP)
TCP/IP TCP/IP
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Miscellaneous Topics
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Security
• SOAP spec says nothing
• Delegated to other levels
– Transport (HTTPS/SSL)
– Virtual Private Networks (VPNs)
• Included in interface semantics
• Needs standardization
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Service Description
• SDL (Service Description Language) MS v1.0
• SCL (Service Contract Language) MS v2.0
• NASSL (Network Accessible Service
Specification Language) IBM v1.0
• WSDL (Web Services Description Language)
– Exposes XML Schema
– Describes Transport Bindings
– Describes Encoding Scheme
Copyright© 2000 Kenn Scribner and Mark C. Stiver
WSDL
• Includes…
– Data types
– Message structure
– Operations
– Protocol bindings
– Addresses
– Services
Copyright© 2000 Kenn Scribner and Mark C. Stiver
See Examples...
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Service Discovery
• UDDI (Universal Description, Discovery and
Integration)
– Defines interface semantics
– Database of services (yellow, white, green pages)
– Uses SOAP messages
• Query
• Inquiry
• Publishing
• ADS (Advertisement and Discovery of Services)
– File that describes your service
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Service Discovery
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Summary
• Integrating processes via the web is key
• XML and HTTP are the enabling technologies
• SOAP defines the encoding scheme
• WSDL describes the service
• UDDI advertises the service
Copyright© 2000 Kenn Scribner and Mark C. Stiver
Resources
• DevelopMentor - [Link]/soap
• SOAP mail list - [Link]
• W3C protocols - [Link]/2000/xp/
• IBM - [Link]
• Microsoft - [Link]
• Apache - [Link]
Copyright© 2000 Kenn Scribner and Mark C. Stiver