SOAP
The primary limitation of HTTP consists in the fact that HTTP-based message exchanges allow only synchronous request-response semantics. To overcome this limitation, SMTP is often used to carry asynchronous messages, but it is a complex protocol and inefficient for passing short and frequent messages that should be delivered in close to real time.
Thus XMPP (see XMPP Core
(Note: The main body of this document provides descriptive text suitable for use by XMPP developers. A formal description of the SOAP XMPP Binding itself is provided in the section of this document entitled SOAP XMPP Binding.)
The usual architecture of XMPP is described in RFC 6120. In essence, XMPP is most commonly deployed using a client-server (or logical peer-to-peer) architecture quite similar to that of the email system, except that XMPP does not have multiple hops between servers, enforces domain names to prevent address spoofing, and enables channel encryption (via TLS) and authentication (via SASL) between client and server as well as among servers.
The binding of SOAP to XMPP assumes that most SOAP-enabled XMPP entities will be implemented as XMPP clients that communicate with other entities as logical peers. However, in order to deploy more scalable services, such entities could also be implemented as server-side components (see Jabber Component Protocol (XEP-0114)
The SOAP specification defines the concepts of "SOAP intermediary" and "ultimate SOAP receiver" (see Section 1.5.3 of SOAP Version 1.2 Part 1). In general, this specification assumes that XMPP entities that support the SOAP XMPP Binding will be ultimate SOAP receivers, since SOAP intermediaries tend to be artifacts of the existing SOAP bindings (HTTP and SMTP) rather than applicable to all possible bindings. SOAP intermediaries are usually deployed in order to (1) cross trust boundaries in protocols that do not enforce domain names or authenticate end-points, (2) ensure scalability, (3) secure messages sent over unencrypted channels, and (4) provide message tracing. However, these issues are addressed natively in XMPP (e.g., channel encryption is defined in RFC 6120), in XMPP extensions (e.g., message tracing is defined in Advanced Message Processing (XEP-0079)
In order to determine whether a potential responding entity supports the SOAP XMPP Binding, a requesting entity SHOULD send a Service Discovery (XEP-0030)
If the responding entity supports the SOAP XMPP Binding and the requesting entity is not blocked from communicating with the responding entity, the responding entity MUST include a feature of "http://jabber.org/protocol/soap" in its reply and SHOULD specify a service discovery identity of "automation/soap".
When a requesting entity wants to interact with a responding entity via the SOAP XMPP Binding, it faces a fundamental choice: to use <iq/> stanzas or to use <message/> stanzas. The following guidelines may prove useful:
Examples of both approaches are provided below, encapsulating the SOAP message examples (a travel reservation flow) to be found in SOAP Version 1.2 Part 0
The transport with <iq/> stanzas is performed in a way similar to that described for XML-RPC in Jabber-RPC (XEP-0009)
Each <iq/> stanza of type "set" MUST contain a SOAP envelope as the first-level child element, since it already represents a properly namespaced XML subtree qualified by the 'http://www.w3.org/2003/05/soap-envelope' namespace.
If the responding entity does not support the SOAP XMPP Binding, it SHOULD return a <service-unavailable/> error:
If a SOAP-related fault occurs, the mappings in Error Handling SHOULD be used.
If the responding entity does not return an error, it MUST respond with an IQ of type "result":
At this point the requesting entity could send another IQ-set:
The process for exchanging SOAP messages using the XMPP <message/> stanza type is effectively no different from the use with <iq/> stanzas, except that message stanzas may be sent to bare JIDs (user@host) rather than full JIDs (user@host/resource), message stanzas may be stored for later delivery, etc. The following business rules apply:
SOAP messages may contain associated (usually binary) data, and XMPP stanzas that encapsulate such SOAP messages could invoke bandwidth restriction settings (commonly called "karma" in XMPP) tuned for normal text chats. The problem could be bypassed by servers having special karma settings for larger messages, or by SOAP-enabled entities being implemented as components rather than XMPP nodes; however, server-to-server communications risk becoming a serious bottleneck, especially in terms of latency and responsiveness when too many large messages are sent. Therefore, it is desirable to support the sending of attachments or files in order to exchange large amounts of binary data associated with SOAP requests and responses. As summarized in the following table, here are four possible methods:
Method | Description | Recommendation | Reasoning |
---|---|---|---|
File Transfer | Negotiate file transfer using SI File Transfer (XEP-0096) |
SHOULD | Recommended approach for file transfer over XMPP (e.g., see Intermediate IM Protocol Suite (XEP-0117) |
Include Link | Represent the binary data as a file, publish it to an accessible file server (e.g., HTTP or FTP URL), and insert a link to the file directly into the XMPP message stanza (via Out-of-Band Data (XEP-0066) |
MAY | Fallback if file transfer is not possible (not all clients can publish to file servers). |
Alternate Transports | Send SOAP XML plus binary data over alternate transports such as WS-Attachments |
SHOULD NOT | These methods are just other transport protocols and would needlessly complicate implementations of SOAP over XMPP. |
MIME | Encode SOAP envelopes and attachments as MIME multipart messages using SOAP 1.2 Attachment Feature |
MUST NOT | XML streams are pure XML and are not MIME-aware. |
The recommended approaches (file transfer and including a link) are described more fully below.
The recommended method for sending associated data is to use the file transfer protocol described in XEP-0096. Because this is the common and standardized method for XMPP entities to transfer large or binary files outside the XMPP band, it SHOULD be used.
In particular, the entity that has the file SHOULD advertise the availability of the associated stream using XEP-0137 by including the SI-pub data extension along with the XMPP <message/> stanza with which the data is associated:
The entity that is to receive the file SHOULD initiate the file transfer process sending an IQ-get to the sender, using the <start xmlns='http://jabber.org/protocol/sipub'/> element. This element contains the 'id' attribute to specify which published stream to retrieve:
If the sender accepts the request, it responds with an IQ-result containing a <starting/> element. This element indicates the stream initiation identifier to be used:
Then the sender begins the stream initiation negotiation:
For details regarding file transfer and advertising of file transfer stream initiation requests, refer to XEP-0096 and XEP-0137.
If the file transfer method is not possible (e.g., because file transfer is not implemented or transfer attempts fails), the entity that is sending the associated data MAY as a fallback publish the associated data as a file (e.g., at an HTTP or FTP URL) and include a link to the file as out-of-band content by including the out-of-band data extension along with the XMPP <message/> stanza with which the data is associated:
Alternatively, if all else fails, the file may be included as a SOAP representation header:
Naturally, in order to maximize the likelihood that the receiver will be able to retrieve the file, the sender MAY include the SI-pub extension, out-of-band-data extension, and SOAP representation header in the message stanza:
WSDL
The definition of an XMPP SOAP transport in WSDL is straightforward. The following rules apply:
The following is an example of a WSDL definition for an endpoint that supports the SOAP XMPP binding: a mythical service that translates Shakespearean English into selected modern languages and dialects.
Although there is no standard procedure for publishing WSDL documents, usually they are made available through HTTP at some URL discoverable with public registries such as UDDI servers. WSDL descriptions for XMPP bindings MAY follow the same publishing process, or MAY be discoverable through Jabber/XMPP specific mechanisms such as Service Discovery (XEP-0030)
Section 4 of SOAP Version 1.2 Part 1
Note: The SOAP XMPP Binding is optional, and SOAP nodes are not required to implement it. A SOAP node that correctly and completely implements the SOAP XMPP Binding as described herein may be said to "conform to the SOAP 1.2 XMPP Binding".
The SOAP XMPP Binding is identified by the following URI:
XMPP is a pure XML streaming protocol used to exchange snippets of structured data called "XML stanzas" (see RFC 6120) between any two network endpoints.
Because XMPP is a direct messaging protocol, it does not possess the equivalent of web methods such as the HTTP GET, PUT, POST, and DELETE methods. Therefore, it is NOT RECOMMENDED for a SOAP node that supports only the SOAP XMPP Binding to provide the "SOAP Web Method Feature" described in Section 6.4 of SOAP Version 1.2 Part 2. (A SOAP gateway between XMPP and HTTP should support the SOAP Web Method Feature in order to ensure interoperability; however, description of such gateways is outside the scope of this document.)
Because XMPP is a pure XML protocol, it does not use MIME types (RFC 2045
XMPP inherently provides request-response semantics via the <iq/> stanza type and <message/> stanza type, where the <iq/> stanza type requires more formality regarding preservation of request-response semantics in the context of synchronous communications, whereas the <message/> stanza provides a looser mapping to request-response semantics as well as the ability to ensure store-and-forward capabilities similar to those provided by email (see the Implementation Notes section of this document). Because both stanza types support request-response semantics, an implementation of the SOAP XMPP Binding MUST support only the following message exchange pattern (MEP) defined in the core SOAP 1.2 specification:
The request-response message exchange pattern is described in Section 6.2 of SOAP Version 1.1 Part 2. For binding instances conforming to the specification of the SOAP XMPP Binding:
The remainder of this section describes the message exchange pattern (MEP) state machine and its relation to XMPP as described in RFC 6120. For the sake of brevity, relative URIs are used (the base URI being http://www.w3.org/2003/05/soap/bindingFramework/ExchangeContext/Role), the string "fail:" is used as a conventional prefix for the namespace http://www.example.org/2001/12/soap/mep/FailureReasons/, and the string "reqresp:" is used as a conventional prefix for the namespace http://www.example.org/2001/12/soap/mep/request-response/. In the state tables below, the states are defined as values of the http://www.w3.org/2003/05/soap/bindingFramework/ExchangeContext/State property (see Section 6.2 of SOAP Version 1.2 Part 2) and are of type xs:anyURI.
The overall flow of the behavior of a Requesting SOAP Node follows the outline state machine description contained in Section 6.2 of SOAP Version 1.2 Part 2. The following subsections describe each state in more detail, where "Requesting SOAP Node" is to be understood as a logical entity made up of the binding and the local SOAP node associated with the XMPP entity that generates a SOAP request.
The following table formally describes the "Init" state of the Requesting SOAP Node in the SOAP XMPP Binding:
Feature | Value / Description |
---|---|
State Name | Init |
Description | Formulate and send request message |
Pre-Conditions | Control of the outbound transport message exchange context is transferred from the local SOAP node to the binding |
Actions | Formulate and send XMPP <iq/> or <message/> request stanza (see table "Init: XMPP Fields (Requesting)") that encappsulates SOAP envelope transferred from local SOAP node to binding |
Post-Conditions | None |
Transitions | See table "Init: Transitions (Requesting)" |
In the "Init" state, an XMPP stanza (either <iq/> or <message/>) is formulated by the Requesting SOAP Node according to the following table:
Field | Value / Description |
---|---|
XMPP Method | For XMPP <iq/> stanzas, the value of the XMPP 'type' attribute MUST be "set"; does not apply to XMPP <message/> stanzas |
Originator | The XMPP address (JID) carried in the reqresp:ImmediateSender property of the message exchange context is encapsulated as the value of the XMPP 'from' attribute; normally this is set by the XMPP server to which the originator connects |
Destination | The XMPP address (JID) carried in the reqresp:ImmediateDestination property of the message exchange context is encapsulated as the value of the XMPP 'to' attribute |
Correlation Request Message ID | As required for XMPP <iq/> stanzas in general and required for XMPP <message/> stanzas sent in the context of the SOAP XMPP Binding, a correlation request message ID is generated by the sender and encapsulated as the value of the XMPP 'id' attribute |
XMPP Stanza Contents | The XML of the SOAP envelope carried in the reqresp:OutboundMessage property of the transport message exchange context is encapsulated as a direct child element of the XMPP <iq/> or <message/> stanza |
The following table summarizes the transitions from the "Init" state of the Requesting SOAP Node:
Event / Condition | Next State | Failure Reason |
---|---|---|
Request Successfully Sent | Requesting | N/A |
Failure to Send Request | Fail | fail:TransmissionFailure |
The following table formally describes the "Requesting" state of the Requesting SOAP Node in the SOAP XMPP Binding:
Feature | Value / Description |
---|---|
State Name | Requesting |
Description | Waiting for correlated XMPP response (Request Message completely sent on exit from Init state) |
Pre-Conditions | Completion of Init state |
Actions | Wait for a receive XMPP response stanza |
Post-Conditions | Instantiate or replace the reqresp:ImmediateSender property with an XMPP address (JID) that denotes the sender of the XMPP response stanza |
Transitions | See table "Requesting: Transitions" |
The following table summarizes the transitions from the "Requesting" state of the Requesting SOAP Node:
Event / Condition | Next State | Failure Reason |
---|---|---|
Received Correlated XMPP Response | Sending+Receiving | N/A |
Reception Failure (various XMPP errors) | Fail | fail:ReceptionFailure |
For a listing of relevant XMPP error conditions, refer to RFC 6120.
The following table formally describes the "Sending+Receiving" state of the Requesting SOAP Node in the SOAP XMPP Binding:
Feature | Value / Description |
---|---|
State Name | Sending+Receiving |
Description | Receive correlated XMPP response including SOAP envelope |
Pre-Conditions | Completion of Receiving state |
Actions | Process XMPP <iq/> or <message/> response stanza and included SOAP envelope, instantiating or replacing the reqresp:InboundMessage property with an infoset representation of the SOAP envelope contained in the XMPP response stanza |
Post-Conditions | Control of the inbound transport message exchange context is transferred from the binding to the local SOAP node |
Transitions | See table "Sending+Receiving: Transitions" |
The following table summarizes the transitions from the "Sending+Receiving" state of the Requesting SOAP Node:
Event / Condition | Next State | Failure Reason |
---|---|---|
Received Well-Formed Response Message | Success | N/A |
Reception Failure (various XMPP errors) | Fail | fail:ReceptionFailure |
Malformed Response Message (invalid SOAP envelope) | Fail | fail:BadRequestMessage |
For a listing of relevant XMPP error conditions, refer to RFC 6120.
A given instance of a request-response transport message exchange terminates when the state "Success" or "Fail" is reached; control over the transport message exchange context returns to the Requesting SOAP Node.
The overall flow of the behavior of a Responding SOAP Node follows the outline state machine description contained in Section 6.2 of SOAP Version 1.2 Part 2. The following subsections describe each state in more detail, where "Responding SOAP Node" is to be understood as a logical entity made up of the binding and the local SOAP node associated with the XMPP entity that responds to a SOAP request.
The following table formally describes the "Init" state of the Responding SOAP Node in the SOAP XMPP Binding:
Feature | Value / Description |
---|---|
State Name | Init |
Description | Receive request message |
Pre-Conditions | None |
Actions | Receive and validate inbound XMPP <iq/> or <message/> request stanza; instantiate or replace the reqresp:ImmediateSender property with an XMPP address (JID) that denotes the sender of the XMPP request; instantiate or replace the reqresp:InboundMessage property with an infoset representation of the included SOAP envelope |
Post-Conditions | Control of the inbound transport message exchange context is transferred from the binding to the local SOAP node |
Transitions | See table "Init: Transitions (Responding)" |
The following table summarizes the transitions from the "Init" state of the Responding SOAP Node:
Event / Condition | Next State | Failure Reason |
---|---|---|
Received Well-Formed Request Message | Receiving | N/A |
Reception Failure (various XMPP errors) | Fail | fail:ReceptionFailure |
Malformed Response Message (invalid SOAP envelope) | Fail | fail:BadRequestMessage |
For a listing of relevant XMPP error conditions, refer to RFC 6120.
The following table formally describes the "Receiving" state of the Responding SOAP Node in the SOAP XMPP Binding:
Feature | Value / Description |
---|---|
State Name | Receiving |
Description | Waiting for local SOAP node to return response message |
Pre-Conditions | Completion of Init state |
Actions | None |
Post-Conditions | Control of the outbound transport message exchange context is transferred from the local SOAP node to the binding |
Transitions | See table "Receiving: Transitions" |
The following table summarizes the transitions from the "Receiving" state of the Responding SOAP Node:
Event / Condition | Next State | Failure Reason |
---|---|---|
Response Message Becomes Available | Receiving+Sending | N/A |
The following table formally describes the "Receiving+Sending" state of the Responding SOAP Node in the SOAP XMPP Binding:
Feature | Value / Description |
---|---|
State Name | Receiving+Sending |
Description | Waiting for local SOAP node to return response message |
Pre-Conditions | Completion of Receiving state |
Actions | Formulate and send XMPP <iq/> or <message/> response stanza (see table "Receiving+Sending: XMPP Fields") |
Post-Conditions | None |
Transitions | See table "Receiving+Sending: Transitions" |
In the "Receiving+Sending" state, an XMPP stanza (either <iq/> or <message/>) is formulated by the Responding SOAP Node according to the following table:
Field | Value / Description |
---|---|
XMPP Method | For XMPP <iq/> stanzas, the value of the XMPP 'type' attribute MUST be "result"; does not apply to XMPP <message/> stanzas |
Originator | The XMPP address (JID) carried in the reqresp:ImmediateSender property of the message exchange context is encapsulated as the value of the XMPP 'from' attribute; normally set by the XMPP server to which the originator connects |
Destination | The XMPP address (JID) carried in the reqresp:ImmediateDestination property of the message exchange context is encapsulated as the value of the XMPP 'to' attribute |
Correlation Request Message ID | As required for XMPP <iq/> stanzas in general and required for XMPP <message/> stanzas sent in the context of the SOAP XMPP Binding, the correlation request message ID is copied from the ID of the request and encapsulated as the value of the XMPP 'id' attribute |
XMPP Stanza Contents | The XML of the SOAP envelope carried in the reqresp:OutboundMessage property of the transport message exchange context is encapsulated as a direct child element of the XMPP <iq/> or <message/> stanza |
The following table summarizes the transitions from the "Receiving+Sending" state of the Responding SOAP Node:
Event / Condition | Next State | Failure Reason |
---|---|---|
Response Message Successfully Sent | Success | N/A |
Failure to Send Response Message | Fail | fail:TransmissionFailure |
A given instance of a request-response transport message exchange terminates when the state "Success" or "Fail" is reached; from the perspective of the Responding SOAP Node, the transport message exchange has completed.
The main body of text that addresses the requirements of the W3C with regard to SOAP bindings is provided in the SOAP XMPP Binding section of this document. The current section addresses only the topic of organizational interaction between the W3C and the XMPP Standards Foundation (XSF)
As was done with XHTML-IM (XEP-0071)
This specification addresses SOAP 1.2 only. This specification may be superseded or supplemented in the future by a XMPP Extension Protocol specification that defines methods for encapsulating content defined by future versions of SOAP as published by the W3C.
Per RFC 6120, XMPP supports XML 1.0 only. If future versions of XMPP support XML 1.1 or subsequent versions, this specification may be modified to address handling of SOAP messages that are encoded in versions other than XML 1.0.
SOAP provides its own encoding scheme for errors due to message processing or application execution, and it uses SOAP envelopes for reporting. In the SOAP HTTP Binding, these errors are mapped to corresponding HTTP status codes. In the SOAP XMPP Binding, they are mapped to the catch-all XMPP error of <undefined-condition/> along with application-specific error condition elements qualified by the 'http://jabber.org/protocol/soap#fault' namespace (this is consistent with RFC 6120, see also Error Condition Mappings (XEP-0086)
The following table provides a mapping between SOAP, HTTP, and application-specific XMPP errors.
SOAP Fault | HTTP Status Code | XMPP Application Error |
---|---|---|
env:DataEncodingUnknown | 500 | <DataEncodingUnknown/> |
env:MustUnderstand | 500 | <MustUnderstand/> |
env:Receiver | 500 | <Receiver/> |
env:Sender | 400 | <Sender/> |
env:VersionMismatch | 500 | <VersionMismatch/> |
Note: When errors are due to the XMPP transport protocol alone and not to the application layer defined by SOAP, errors MUST be reported with standard XMPP error codes only instead of the XMPP <undefined-condition/> condition plus application-specific condition.
Because XMPP does not require the parsing of arbitrary and complete XML documents and does not require implementations to support the full XML specification, transported SOAP envelopes MUST comply with the XML restrictions specified in RFC 6120. In particular, all envelope elements MUST be properly namespaced (SOAP allows elements within the default namespace, but they are deprecated since SOAP 1.2).
SOAP envelopes may contain arbitrary data encoded in valid XML as well as byte arrays encoded with SOAP-specific elements. The SOAP specification recommends to encode byte arrays in Base 64 (see RFC 3548
SOAP has been supplemented by several support protocols that help ensure message integrity and confidentiality (WS-Security
No interaction with the Internet Assigned Numbers Authority (IANA)
The XMPP Registrar
The XMPP Registrar includes a Service Discovery type of "soap" within the "automation" category.
The registry submission is as follows:
automation
soap
A SOAP receiver (either intermediate or ultimate).
XEP-0072
]]>
Because the SOAP envelope is included as a first-level child element of an <iq/> or <message/> stanza via standard XMPP extension mechanisms, an XML schema is not required for this document. An XML schema for the SOAP envelope element is provided at <http://www.w3.org/2003/05/soap-envelope/>.
The protocol documented by this schema is defined in
XEP-0072: http://www.xmpp.org/extensions/xep-0072.html
]]>
This section is non-normative.
An XMPP entity that supports the SOAP XMPP binding could function as a "SOAP intermediary" that hands a SOAP message off to some other deployment for subsequent processing (HTTP, email, a specialized enterprise messaging platform, etc.) rather than functioning as the "ultimate SOAP receiver" for the message (as these terms are defined in Section 1.5.3 of SOAP Version 1.2 Part 1). If the intended recipient functions as a SOAP intermediary, implementations should be aware that subsequent processing may alter the representation of SOAP messages.
As an example, consider a component that functions as a gateway between XMPP-based and HTTP-based web services. Its purpose might be to mix HTTP and XMPP for web services and to invoke any web services already accessible through HTTP from XMPP clients.
WS-Routing, whose aim is to dynamically compose SOAP message paths and processing sequences, can be used in order to reference web services outside of an XMPP network from within it. WS-Routing extends SOAP Envelope Headers with the <path/> element, which specifies the following for the message: the sender's URL (<from/>), the final destination's URL (<to/>), a forward (<forward/>) path with an arbitrary number of intermediaries (<via/>), and an optional return path (<reverse/>). Each intermediary MUST process the <path/> header and update it accordingly to the already performed path; moreover it MAY process the Body of the message.
A SOAP message originated by an XMPP entity ('xmpp:orig@A.example.com/soap'), and directed to an end point accessible through HTTP ('http://C.example.net/some/endpoint'), could be built using a <path/> header having:
Then the SOAP message can be sent within an <iq/> stanza to the gateway's JID. The gateway processes the SOAP headers, and looking through the headers it discovers that it must act only as intermediary. From the <to/> element it reads the URL of the final end point, extracts the SOAP action, changes the path removing the step already performed, and issues an HTTP request with the modified envelope and appropriate HTTP headers. Once it has received a response, it prepares a new <iq/> stanza of type "result" or "error" and sends its reply to the original requester. The following example shows the possible SOAP headers of the described process.
Generic XMPP routers that conform to RFC 6120 may also "store and forward" Jabber messages. This feature is usually called "offline message handling": the router makes a decision as to whether to deliver the message to the local intended recipient based on the recipient's presence, and if the recipient is offline when the router processes the message then it may store the message for delivery when the recipient next comes online (rather than returning an error to the sender). Although it is possible to write an XMPP router that directly supports the SOAP XMPP binding and implements the SOAP processing model, generic XMPP routers do not contain such support. Accordingly, generic XMPP routers will not forward an XMPP message to an alternate SOAP transport such as HTTP or SMTP, or provide other functions of a SOAP intermediary or ultimate receiver. When a generic XMPP router delivers a message to the intended recipient (whether immediately or as delayed in "offline storage") and the intended recipient supports the SOAP XMPP binding, SOAP processing is performed; such an intended recipient MAY act either as a SOAP intermediary or as an ultimate SOAP receiver.
With regarding to exchange of associated data, an XMPP entity that functions as a gateway to other SOAP bindings it SHOULD use W3C-recommended protocols for transporting SOAP attachments over non-XMPP SOAP bindings (e.g., HTTP and SMTP) when communicating with non-XMPP entities.
Many thanks to Noah Mendelsohn for his assistance regarding SOAP binding definitions and conformance issues. Thanks also to Michael Mahan and Rich Salz for their comments.
Some text in the SOAP XMPP Binding section of this document is closely modelled on Section 7 of SOAP Version 1.2 Part 2 and on SOAP Version 1.2 Email Binding.