Escolar Documentos
Profissional Documentos
Cultura Documentos
SOAP in a nutshell
SOAP is a protocol specification for invoking methods on servers,
services, components and objects. SOAP codifies the existing practice
of using XML and HTTP as a method invocation mechanism. The
SOAP specification mandates a small number of HTTP headers that
facilitate firewall/proxy filtering. The SOAP specification also
mandates an XML vocabulary that is used for representing method
parameters, return values, and exceptions. [DevelopMentor]
W3C
July 9, 2001
W3C Releases First Public Working Draft
for SOAP Version 1.2
Working draft produced by the XML
Protocol Working Group.
Specification can be found:
http://www.w3.org/TR/soap12/
Motivation
SOAP suds
SOAP IS:
Lightweight communication protocol
For communication between applications
one-way, request/response, multicast, etc..
Envelope
Defines the content of the message
Header (optional)
contains header information
Body
contains call and response information
Envelope
SOAP Namespaces
Header
Body
SYNTAX RULES
Error messages from a SOAP application are carried inside a Fault element.
Must appear as an element w/in the <Body> element and can only appear once in a SOAP message.
Fault sub elements:
<faultcode>
MUST: --code identifying the error, for use by the software
<faultstring>
MUST: --error as a string
<faultactor>
MUST(Apps not acting as ultimate destination of SOAP message)
--who caused the error
<detail>
MUST(if contents of Body could not be successfully processed)
--specific error information
Fault Codes:
VersionMismatch Invalid namespace for the SOAP Envelope Element
MustUnderstand
A child element of the Header element, with the mustUnderstand attribute
set to 1, was not understood
Client
The message was incorrectly formed or contained incorrect information.
Server
There was a problem with the server so the message could not be process
Example:
<env:Fault>
<faultcode>env:MustUnderstand</faultcode>
<faultstring>SOAP Must Understand Error</faultstring>
</env:Fault>
Easy Transport.HTTP
Why HTTP?
HTTP has a request/response model allowing SOAP to
embed request parameters in HTTP request, and SOAP
response parameters into HTTP responses.
HTTP apps MUST use the media type text/xml when
including SOAP entity bodies in HTTP messages.
Content-Type: text/xml; charset=utf-8
Sent from the client to the service. First few lines are HTTP headers and SOAP HTTP
headers. Followed by the SOAPAction HTTP header and SOAP Envelope XML
element. The SOAP Body contains application defined element(s), as defined by the
service.
<env:Envelope xmlns:env=http://www.w3.org/2001/06/soap-envelope>
<env:Body>
<m:GetStockQuoteResponse xmlns:m=Some-URI
env:encodingStyle=http://www.w3.org/2001/06/soap-encoding>
<price>5.00</price>
</m:GetStockQuoteResponse>
</env:Body>
</env:Envelope>
Client/Server
SOAP box
<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope">
<env:Header>
<n:alertcontrol xmlns:n="http://example.org/alertcontrol">
<n:priority>1</n:priority>
<n:expires>2001-06-22T14:00:00-05:00</n:expires>
</n:alertcontrol>
</env:Header>
<env:Body>
<m:alert xmlns:m="http://example.org/alert">
<m:msg>Pick up Mary at school at 2pm</m:msg>
</m:alert>
</env:Body>
</env:Envelope>