Professional Documents
Culture Documents
SOAP
Simple Object Access Protocol
Motivations
Heterogeneous systems must be able to communicate Binary protocols dont always work
CORBA, DCOM, etc. dont work well through firewalls Nobody can agree on a standard binary format (usually due to platform-related issues) Were dealing with many heterogeneous environments (MVS, Unix, Windows NT, Linux, PalmOS, etc.) Component runtimes differ Security models differ (Kerberos, NTLM, OSF-DCE)
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
Enter SOAP...
SOAP Encoding
Envelope package Header/Body pattern
Similar to how HTTP works
Header
Body
Header
Out-of-band information such as
Authentication information Message routes Logging Transaction flow
Body
Interface-specific information such as
RPC method name and parameters Serialized objects (instances of types) Messages
Simple Example
<Envelope> <Header> <transId>1234</transId> </Header> <Body> <Add> <a>3</a> <b>4</b>
c = Add(a, b)
</Add>
</Body> </Envelope>
Copyright 2000 Kenn Scribner and Mark C. Stiver
<Envelope> <Header> <transId>1234</transId> </Header> <Body> <AddResponse> <c>7</c> </AddResponse> </Body> </Envelope>
Binding to a transport
HTTP header fields
XML Namespaces
Default namespace
<Book xmlns=Some-URI>
<Author>Tom Clancy</Author>
</Book>
Unqualified element
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
Analyzing a Request
<SOAP-ENV:Envelope
Analyzing a Request
...etc... <SOAP-ENV:Header>
Qualifies transId
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 NS qualifies entire message
<SOAP-ENV:Body> <m:Add xmlns:m=http://a.com/Calculator>
<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=http://schemas.xmlsoap.org/soap/envelope/ SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/> <SOAP-ENV:Header> <t:transId xmlns:t=http://a.com/trans>1234</t:transId> </SOAP-ENV:Header> <SOAP-ENV:Body> <m:AddResponse xmlns:m=http://a.com/Calculator> <c xsi:type=integer>7</c> </m:AddResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Serializing Types
Arrays
Arrays
int a[3] = {1, 2, 3}; b = Add([in]a);
<m:Add xmlns:m=http://a.com/Calculator xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/> <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>
SOAPAction
This is my intent! POST /Calculator.pl HTTP/1.0 Host: www.a.com Accept: text/* Content-type: text/xml Content-length: nnnn SOAPAction: http://www.a.com/Calculator#Add {CR}{LF} <SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/> <SOAP-ENV:Header> <t:transId xmlns:t=http://a.com/trans>1234</t:transId> </SOAP-ENV:Header> <SOAP-ENV:Body> <m:Add xmlns:m=http://a.com/Calculator> ...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=http://schemas.xmlsoap.org/soap/envelope/ SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>Internal Application Error</faultstring> <detail xmlns:f=http://www.a.com/CalculatorFault> <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
Application
Web Service
Interface Semantics
Envelope/Header/Body
Interface Semantics
Envelope/Header/Body
Message Encoding
SOAP
Message Encoding
Miscellaneous Topics
Security
SOAP spec says nothing Delegated to other levels
Transport (HTTPS/SSL) Virtual Private Networks (VPNs)
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
See Examples...
Service Discovery
UDDI (Universal Description, Discovery and Integration)
Defines interface semantics Database of services (yellow, white, green pages) Uses SOAP messages
Query Inquiry Publishing
Service Discovery
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
Resources
DevelopMentor - www.develop.com/soap SOAP mail list - discuss.develop.com W3C protocols - www.w3.org/2000/xp/ IBM - alphaworks.ibm.com Microsoft - msdn.microsoft.com Apache - xml.apache.org