You are on page 1of 17

Matt Baker

Understanding SOAP University of Arkansas


mmb05@uark.edu
What is SOAP?

• Simple Object Access Protocol


• XML-based
• Normally runs over HTTP
• Lightweight message-passing method for
distributed systems
“S” is for Simple

• SOAP is a communication standard; only


one part of distributed service

Two major design goals for SOAP are simplicity and extensibility. SOAP
attempts to meet these goals by omitting features that are often found in
distributed systems. Such features include "reliability", "security", "correlation",
"routing", and "Message Exchange Patterns" (MEPs). Other features are left to
be defined as extensions by other specifications.

http://www.w3.org/TR/soap12-part1/#intro
Where does SOAP fit?
User calls web service, passing any
SOAP parameters necessary

Register service with server; allows


UDDI users to search for services

Define web service (location, value types,


WSDL return types, etc.)

Application written in any language,


Web Service platform or server configuration
What’s SOAP made of?
SOAP envelope
<?xml version="1.0"?>
Header - Contains <soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
requirements specific soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
to message
<soap:Header>
optional <m:Trans
xmlns:m="http://www.w3schools.com/transaction/"
Body - Information soap:mustUnderstand="1">234</m:Trans>
used by applications </soap:Header>
(object data, error
messages, return <soap:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
values) <m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>

</soap:Envelope>
required
SOAP: Header
• Actor (a.k.a. role in SOAP 1.2)
• Single message can be routed to multiple
nodes (sent to a security node, then
routed to a charging node, for example)
• mustUnderstand
• Similar to a required function parameter
• mustUnderstand=”1” means service
(or actor) MUST processed by recipient
SOAP: Body
Request
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
• Child elements
<soap:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
are defined by
<m:Item>Apples</m:Item>
</m:GetPrice> service’s
</soap:Body>
</soap:Envelope> namespace
Response • Namespaces
<?xml version="1.0"?>
(xmlns:) helps
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope" determine which
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<m:GetPriceResponse
function to call
xmlns:m="http://www.w3schools.com/prices"> (call GetPrice from
<m:Price>1.90</m:Price>
</m:GetPriceResponse> w3schools.com)
</soap:Body>
</soap:Envelope>
SOAP Faults
• Fault elements defined by SOAP’s default
namespace
• Fault elements
• <faultcode> identifies error to application
• VersionMismatch error: wrong version of SOAP used
• MustUnderstand error: Header element not recognized
• Client error: If caller (client) sends malformed message
• Server error (most common): Error processing at server
• <faultstring> identifies error to client
• <faultactor> identifies where error took place
• <detail> better debug info (line number, etc.)
SOAP Faults
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<soap:Fault>
<faultcode>soap:MustUnderstand</faultcode>
<faultstring>Mandatory Header error.</faultstring>
<faultactor>http://www.wrox.com/heroes/endpoint.asp</faultactor>
<detail>
<w:source xmlns:w="http://www.wrox.com/">
<module>endpoint.asp</module>
<line>203</line>
</w:source>
</detail>
</soap:Fault>

</soap:Body>
</soap:Envelope>

Sample Fault Response


SOAP discovery: WSDL

• Web Service Description Language


• XML that defines a web service
• Describes namespaces, data types, message
types, function names
• Think of it as a machine-readable JavaDoc
for a Web Service
What’s WSDL made of?
<definitions name="DefinitionsName"
Definitions targetNamespace="NamespaceURI"
xmlns:prefix="NamespaceURI"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
Types - Defines data xmlns:xsd="http://www.w3.org/2001/XMLSchema"
types used in SOAP xmlns="http://schemas.xmlsoap.org/wsdl/">
message. <types>
<xsd:complexType name="WeatherSummary">
<xsd:sequence>
optional <xsd:element maxOccurs="1" minOccurs="1" name="zipcode"
nillable="true" type="xsd:string"/>
Message - Describes <xsd:element maxOccurs="1" minOccurs="1" name="temp"
nillable="true" type="xsd:int"/>
messages the service </xsd:sequence>
responds to </xsd:complexType>
</types>
<message name="getSummary">
required <part name="zipcode" type="xsd:string"/>
</message>
Port - Defines the <message name="getSummaryResponse">
service; determines <part name="return" type="wsx:WeatherSummary"/>
</message>
order of operations <portType name="WeatherSummary">
<operation name="getSummary">
required <input message="tns:getSummary"/>
<output message="tns:getSummaryResponse"/>
</operation>
Binding - Describes </portType>
protocols to use <service name="WeatherSummary">
<documentation>WeatherSummary</documentation>
required <port binding="tns:WeatherSummary" name="WeatherSummary">
<soap:address
Service - shows URL location="http://localhost:8090/weather/WeatherSummary"/>
</port>
required </service>
</definitions>
An example

UDDI: Universal
Description, Discovery
and Integration

JAXR: Java API for


XML Registries
Demo
Speed of SOAP

Using XMLBlaster on a 600Mhz Linux server. From http://www.xmlblaster.org/performance.html

• Not the fastest messaging service out there


• XML very detailed, tag-heavy
• Relies on HTTP over Internet
SOAP Advantages

• Human-readable XML
• Easy to debug
• SOAP runs over HTTP
• Firewalls not affected
• Services can be written in any language,
platform or operating system
Disadvantages
• S-L-O.......................................W
• XML produces a lot of overhead for small
messages
• Web Service speed relies on Internet
traffic conditions
• Not strictly-typed XML
• DTD’s, namespaces not explicitly required
Sources
SOAP Tutorial http://www.w3schools.com/soap/default.asp

WSDL Tutorial http://www.w3schools.com/wsdl/wsdl_syntax.asp

Overview of WSDL http://developers.sun.com/sw/building/tech_articles/


overview_wsdl.html

WSDL at RogueWave http://www.roguewave.com/support/docs/leif/leif/html/


soapworxug/13-1.html

The Almighty Google http://www.google.com/search?q=soap+tutorial&ie=UTF


-8&oe=UTF-8

SOAP Faults http://msdn.microsoft.com/library/default.asp?url=/library/


en-us/dnservice/html/service09172002.asp
CORBA / RMI / XML http://www.xmlblaster.org/performance.html
benchmarks in Java

You might also like