Académique Documents
Professionnel Documents
Culture Documents
DarkSwitch 2010
! <soap:Body xmlns:m=”http://www.example.org/stock”>
! ! <m:GetStockPrice>
! ! ! <m:StockName>IBM</m:StockName>
! ! </m:GetStockPrice>
! </soap:Body>
! </soap:Envelope>
SOAP Advantages:
• It can use different transport protocols
SOAP Disadvantages:
• Itʼs slower than CORBA cause it uses XML format
• In some cases, when SOAP is transported by HTTP, if the firewalls want inspect the
contents of the package it must have some knowledge of the SOAP structure. So, this
operation could be very expensive for the Firewall.
• Not all languages offer appropriate support for it.
1. SOAP introduction
Soap is a simple XML-based protocol to let applications exchange information over HTTP
Todayʼs applications communicate using Remote Procedure Calls (RPC) between objects
like DCOM and CORBA, but HTTP was not designed for this. RPC represents a
compatibility and security problem; firewalls and proxy servers will normally block this kind
of traffic.
2. SOAP Syntax
A SOAP message is an ordinary XML document containing the following elements:
• Envelope: Identifies the XML document as a SOAP message
• Header: contains header information
• Body: Contains call and response information
• Fault: Contains errors and status information
Syntax rules:
• A SOAP message MUST be encoded using XML
• A SOAP message MUST use the SOAP Envelope namespace
• A SOAP message MUST use the SOAP encoding namespace
• A SOAP message must NOT contains a DTD reference
• A SOAP message must NOT contains XML Processing Instructions
3. SOAP envelope
The SOAP Envelope element is the root element of a SOAP message.
A SOAP message has no default encoding.
Example:
" <?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”>
! ! ....
! ! Message information goes here
! ! ...
! </soap:Envelope>
! soap:encodingStyle=”http://www.w3.org/2001/12/soap-encoding”>
! <soap:Header>
! ! <m:Trans xmlns:m=”http://www.w3scholls.com/transaction/”
! ! soap:mustUnderstand=”1”>234
! ! </m:Trans>
! </soap:Header>
! ....
! ....
! </soap:Envelope>
Syntaxis:
soap:mustUnderstand=”0|1”
It indicates that the receiver processing the Header must or not recognize the element. If
the receiver does not recognize the element it will fail when processing the Header.
Syntaxis:
soap:actor =”URI”
A SOAP message may travel from a sender to a receiver by passing different endpoints
along the message path. However, not all parts of a SOAP message may be intended for
the ultimate endpoint, instead, it may be intended for one or more of the endpoints on the
message path.
The SOAP actor attribute is used to address the Header element to a specific endpoint.
The encodingStyle attribute is used to define the data types used in the document.
5. SOAP Body
The SOAP Body element contains the actual SOAP message intended for the ultimate
endpoint of the message.
Example: Request
! <soap:Body>
! ! <m:GetPrice xmlns:m=”http://www.w3schools.com/price”>
! ! ! <m:Item>Apples</m:Item>
! ! </m:GetPrice>
! </soap:Body>
! </soap:Envelope>
Example: Response
! <?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>
! ! <m:GetPriceResponse xmlns:m=”http://www.w3schools.com/prices”>
! ! ! <m:Price>1.90</m:Price>
! ! </m:GetPriceResponse>
! </soap:Body>
! </soap:Envelope>
6. SOAP Fault
The SOAP Fault element hold errors and status information for a SOAP message.
7.1 Content-Type
Syntaxis:
Content-Type: MIMEType; charset=character-encoding
The Content-Type header for a SOAP request and response defines the MIME type of the
message and the character encoding (optional) used for the XML body of the request or
response.
Example:
7.2 Content-Length
Syntaxis:
Content-Length: bytes
V 1.1 Last modification: 27/05/2010! Page 4
Programming Web Services - Lec. 3.1 SOAP! DarkSwitch 2010
The Content-Length header for a SOAP request and response specifies the number of
bytes in the body of the request or response
Example:
8. SOAP Example
In this example, a GetStockPrice request is sent to a server. The request has a
StockName parameter, and a Price parameter that will be returned in the response. The
namespace for the functions defined in “http://www.example.org/stock”
Example: (Request)
! <soap:Body xmlns:m=”http://www.example.org/stock”>
! ! <m:GetStockPrice>
! ! ! <m:StockName>IBM</m:StockName>
! ! <m:GetStockPrice>
! </soap:Body>
Example: (Response)
! <?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 xmlns:m=”http://www.example.org/stock”>
! ! <m:GetStockPriceResponse>
! ! ! <m:Price>34.5</m:Price>
! ! </m:GetStockPriceResponse>
! </soap:Body>
http://www.ict.kth.se/courses/ID2208/2010/lectures/SOAP2010.pdf
1. Introduction
To achieve XML-based interaction, developers need to establish a standard transport and
data-exchange framework
2. Definition of SOAP
SOAP provides:
• A mechanism for defining the unit of communication
• a processing model
• a mechanism for error handling
• an extensibility mechanism
• a flexible mechanism for data representation
• a convention for representing RPCs and responses as SOAP messages
• a binding mechanism for SOAP messages to HTTP
SOAP supports
• a Document centric approach for documents exchange
SOAP messages donʼt provide programming instructions - they rather specify which
operation to invoke
3. SOAP Elements
As not endpoint user of a SOAP message, we can put everything in the header. The
important thing is that someone can understand it and we havenʼt change the original
message.
4. SOAP Fault
Codes:
• Seder: The problem was caused by incorrect or missing data from the sender
• Receiver: The problem because of something happens on receiver side.
• Version/Mismatch: Indicates the node does not recognize the version of SOAP used
• MustUnderstand: Indicates the node does not recognize a block flagged with
mustUnderstand.
• Subcodes: More fine-grain fault codes
• Reason: Contains huma-readable description
V 1.1 Last modification: 27/05/2010! Page 7
Programming Web Services - Lec. 3.1 SOAP! DarkSwitch 2010
• Node: Shows the node which processed the message at the time of fault.
• Role: Tells which role the faulting node was playing when the fault occurred.
There is no standard SOAP mapping for any language (For example, JAVA).
The most basic rule is that values are always encoded in elements.
SOAP uses attributes exclusively to modify the default processing of an element.
For example:
Example:
You can encode some files (ex. picture) into binary in order to include it to SOAP
Example:
6. Messaging
The MIME media type of both HTTP requests and responses muse be application/soap
+xml