<<

SOAP Message Exchange Patterns • SOAP is defined as a one-way message transmission protocol, however real applications use various message exchange patterns (MEP) to communicate SOAP messages. • A familiar example of a MEP is that which occurs between a and a Web server when exchanging HTML embedding in an HTTP message Internet

HTTP Request

HTTP Response

Web Browser Web Server HTTP Request-Response SOAP Message Exchange Patterns • The MEPs that can be used depend on what the underlying transport protocol supports. • SOAP was designed to be independent of the underlying protocol, so it only defines SOAP as one-way. • However, the SOAP designers fully expect SOAP messages to be combined in various exchange patterns, and therefore, they abstractly describe two MEPs in the SOAP specification: Request-Response and SOAP Response

SOAP Request Message Sender Receiver SOAP Response Message Request-Response MEP SOAP Message Exchange Patterns

Non-SOAP Message

Sender Receiver SOAP Response Message

SOAP Response MEP

• Other forms of MEPs are One-Way, Notification, Single Request/Multiple Response, and Solicit-Response. • One-Way and Request-Response are the most popular MEPs in use today. Both are supported by HTTP, which is the most commonly used method for transporting SOAP messages. SOAP Message Structure • A SOAP message is simply an XML document with it’s own XML schema, XML namespaces, and processing rules. • The XML document that defines a SOAP message is composed of the following four elements: • Envelope (mandatory) – Root of the XML document. • Header (optional) – An extension mechanism that can be used to pass application-specific information not contained in the message itself. • Body (mandatory) – Contains the application data that is being transported between applications. • Fault (optional) – Used to report errors back to a SOAP sender. Analogous to an Exception in Java. SOAP Message Structure, cont. •The SOAP Envelope is a package for data (a message) that is transported from a sender node to a receiver node.

<…> <…> <…> <…> Normal SOAP Message SOAP Message with a Fault Structure of a SOAP Message with and without a Fault SOAP Message Structure, cont. • Besides XML text data, SOAP can also transmit binary data. This is often done using XML references to Multipurpose Internet Mail Extensions (MIME) in HTTP.

POST /aPostExample HTTP/1.1 Host: www.example.com Content-Type: Multipart/Related; ... Content-Length: XXX HTTP Headers

SOAP Message ... Refers To

E01DGkj4DtE/NWEDBidw3/DKB4dKLEW90// DIGEi45dEICG45IOl/DaIkgkeislIODe93 ... Attachments (possibly KIIx4kIELO30EGBDGIEBiide93w4IDKOl23KIL GIF, JPEG, PDF, etc) DGKED45kelsqiud412jkIWEPOWJAGEl2KI ...

SOAP in HTTP Message with MIME Attachments XML Namespaces in SOAP • XML namespaces are used in SOAP to eliminate ambiguity (prefixes help distinguish between elements or attributes with the same name), provide versioning and processing control, and support modularity. • The SOAP XML elements are defined in the SOAP XML schema. The namespace for the SOAP schema is: – (version 1.1) http://schemas.xmlsoap.org/soap/envelope – (version 1.2) http://www.w3.org/2003/05/soap- envelope • The difference between the SOAP 1.1 and 1.2 namespace is an example of versioning. • Different XML namespaces can be used for the different parts of the SOAP message (SOAP schema elements, header blocks, and XML in the Body), thus code that processes one part can change while the code that processes the other parts can remain the same (modularity). XML Namespaces in SOAP, cont. • The SOAP schema requires that local elements (including their attributes) be fully qualified via the use of prefixes or default namespaces. • Additionally the WS-I BP requires that all local elements within the SOAP Body be fully qualified as well. • The local elements of header blocks may be qualified or unqualified, although the best practice is to qualify them.