SOAP 1.2

Editors Copy, Last Modified: $Date: 2001/08/16 14:54:41 $ UTC 2001

This version:
http://www.w3.org/2000/xp/Group/1/06/01/soap-02-infoset.html
Latest version:
http://www.w3.org/2000/xp/Group/1/06/01/soap-02-infoset.html
Previous versions:
http://www.w3.org/TR/2001/WD-soap12-20010709
Editors:
Martin Gudgin, DevelopMentor
Marc Hadley, Sun Microsystems
Jean-Jacques Moreau, Canon
Henrik Frystyk Nielsen, Microsoft

Abstract

SOAP version 1.2 is a lightweight protocol for exchange of information in a decentralized, distributed environment. It is an XML based protocol that consists of four parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined data types, a convention for representing remote procedure calls and responses and a binding convention for exchanging messages using an underlying protocol. SOAP can potentially be used in combination with a variety of other protocols; however, the only binding defined in this document describes how to use SOAP in combination with HTTP.

Status of this Document

This document is an editors' copy that has no official standing.

Editorial note: MJH20010731
This is an editors' copy that has absolutely no standing. The purpose of this editors copy is to show several sections rewritten from the perspective of the XML Infoset[13].

Comments on this document should be sent to xmlp-comments@w3.org[1]. It is inappropriate to send discussion emails to this address.

Discussion of this document takes place on the public xml-dist-app@w3.org mailing list[2] per the email communication rules in the XML Protocol Working Group Charter[3].

Table of Contents

1 Introduction
    1.1 Design Goals
    1.2 Notational Conventions
    1.3 Examples of SOAP Messages
    1.4 SOAP Terminology
        1.4.1 Protocol Concepts
        1.4.2 Data Encapsulation Concepts
        1.4.3 Message Sender and Receiver Concepts
        1.4.4 Data Encoding Concepts
2 The SOAP Message Exchange Model
    2.1 SOAP Nodes
    2.2 SOAP Actors and SOAP Nodes
    2.3 Targeting SOAP Header Blocks
    2.4 Understanding SOAP Headers
    2.5 Processing SOAP Messages
3 Relation to XML
4 SOAP Envelope
    4.1 Envelope Encoding and Versioning
        4.1.1 SOAP encodingStyle Attribute
        4.1.2 Envelope Versioning Model
    4.2 SOAP Header
        4.2.1 Use of Header Attributes
        4.2.2 SOAP actor Attribute
        4.2.3 SOAP mustUnderstand Attribute
    4.3 SOAP Body
        4.3.1 Relationship between SOAP Header and Body
    4.4 SOAP Fault
        4.4.1 SOAP Fault Codes
        4.4.2 MustUnderstand Faults
5 SOAP Encoding
    5.1 Rules for Encoding Types in XML
    5.2 Simple Types
        5.2.1 Strings
        5.2.2 Enumerations
        5.2.3 Array of Bytes
    5.3 Polymorphic Accessor
    5.4 Compound Types
        5.4.1 Compound Values and References to Values
        5.4.2 Arrays
            5.4.2.1 PartiallyTransmitted Arrays
            5.4.2.2 SparseArrays
        5.4.3 Generic Compound Types
    5.5 Default Values
    5.6 SOAP root Attribute
6 Using SOAP in HTTP
    6.1 SOAP HTTP Request
        6.1.1 The SOAPAction HTTP Header Field
    6.2 SOAP HTTP Response
    6.3 The HTTP Extension Framework
    6.4 SOAP HTTP Examples
7 Using SOAP for RPC
    7.1 RPC and SOAP Body
    7.2 RPC and SOAP Header
    7.3 RPC Faults
8 Security Considerations
9 References
    9.1 Normative References
    9.2 Informative References

Appendices

A Version Transition From SOAP/1.1 to SOAP Version 1.2
B SOAP Envelope Examples (Non-Normative)
    B.1 Sample Encoding of Call Requests
    B.2 Sample Encoding of Response
C Acknowledgements (Non-Normative)
D Change Log (Non-Normative)
    D.1 SOAP Specification Changes
    D.2 XML Schema Changes


1 Introduction

SOAP version 1.2 provides a simple and lightweight mechanism for exchanging structured and typed information between peers in a decentralized, distributed environment using XML. SOAP does not itself define any application semantics such as a programming model or implementation specific semantics; rather it defines a simple mechanism for expressing application semantics by providing a modular packaging model and encoding mechanisms for encoding application defined data. This allows SOAP to be used in a large variety of systems ranging from messaging systems to remote procedure calls (RPC).

SOAP consists of four parts:

  1. The SOAP envelope (4 SOAP Envelope) construct defines an overall framework for expressing what is in a message, who should deal with it, and whether it is optional or mandatory.

  2. The SOAP encoding rules (5 SOAP Encoding) defines a serialization mechanism that can be used to exchange instances of application-defined datatypes.

  3. The SOAP binding (6 Using SOAP in HTTP) defines a convention for exchanging SOAP envelopes between peers using an underlying protocol for transport.

  4. The SOAP RPC representation (7 Using SOAP for RPC) defines a convention that can be used to represent remote procedure calls and responses.

To simplify the specification, these four parts are functionally orthogonal. In particular, the envelope and the encoding rules are defined in different namespaces.

This specification defines a SOAP binding that describes how a SOAP message can be carried in HTTP[4] messages.

1.2 Notational Conventions

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [5].

The namespace prefixes "env" and "enc" used in the prose sections of this document are associated with the SOAP namespace names "http://www.w3.org/2001/06/soap-envelope" and "http://www.w3.org/2001/06/soap-encoding" respectively.

The namespace prefixes "xs" and "xsi" used in the prose sections of this document are associated with the namespace names "http://www.w3.org/2001/XMLSchema" and "http://www.w3.org/2001/XMLSchema-instance" respectively, both of which are defined in the XML Schemas specification[6],[7].

Note that the choice of any namespace prefix is arbitrary and not semantically significant.

Namespace URIs of the general form "http://example.org/..." and "http://example.com/..." represent an application-dependent or context-dependent URI[8].

This specification uses the augmented Backus-Naur Form (BNF) as described in [4].

1.3 Examples of SOAP Messages

The following example shows a simple notification message expressed in SOAP. The message contains the header block alertcontrol and the body block alert which are both application defined and not defined by SOAP. The header block contains the parameters priority and expires which may be of use to intermediaries as well as the ultimate destination of the message. The body block contains the actual notification message to be delivered.

Example: SOAP message containing a header block and a body block
<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>

SOAP messages may be bound to different underlying protocols and used in a variety of message exchange patterns. The following two examples show SOAP used in connection with HTTP as the underlying protocol taking advantage of the request/response mechanism provided by HTTP (6 Using SOAP in HTTP).

The following example shows a sample SOAP/HTTP request. The SOAP/HTTP request contains a block called GetLastTradePrice which takes a single parameter, the ticker symbol for a stock. As in the previous example, the GetLastTradePrice element is not defined by SOAP itself. The service's response to this request contains a single parameter, the price of the stock. The SOAP Envelope element is the top element of the XML document representing the SOAP message. XML namespaces are used to disambiguate SOAP identifiers from application specific identifiers.

Example: Sample SOAP Message embedded in an HTTP Request
POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "http://example.org/2001/06/quotes"

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope" >
 <env:Body>
  <m:GetLastTradePrice
        env:encodingStyle="http://www.w3.org/2001/06/soap-encoding"
        xmlns:m="http://example.org/2001/06/quotes">
    <symbol>DIS</symbol>
  </m:GetLastTradePrice>
 </env:Body>
</env:Envelope>

The following example shows the SOAP message sent by the StockQuote service in response to the request shown in the preceeding example.

Example: Sample SOAP Message embedded in an HTTP Response
HTTP/1.1 200 OK
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope" >
 <env:Body>
  <m:GetLastTradePriceResponse
        env:encodingStyle="http://www.w3.org/2001/06/soap-encoding"
        xmlns:m="http://example.org/2001/06/quotes">
   <Price>34.5</Price>
  </m:GetLastTradePriceResponse>
 </env:Body>
</env:Envelope>

More examples are available in B SOAP Envelope Examples.

1.4 SOAP Terminology

2 The SOAP Message Exchange Model

SOAP messages are fundamentally one-way transmissions from a SOAP sender to a SOAP receiver, but as illustrated above, SOAP messages are often combined to implement patterns such as request/response.

SOAP implementations can be optimized to exploit the unique characteristics of particular network systems. For example, the HTTP binding described in 6 Using SOAP in HTTP provides for SOAP response messages to be delivered as HTTP responses, using the same connection as the inbound request.

2.2 SOAP Actors and SOAP Nodes

In processing a SOAP message, a SOAP node is said to act in the role of one or more SOAP actors, each of which is identified by a URI known as the SOAP actor name. Each SOAP node MUST act in the role of the special SOAP actor named "http://www.w3.org/2001/06/soap-envelope/actor/next", and can additionally assume the roles of zero or more other SOAP actors. A SOAP node can establish itself as the ultimate SOAP receiver by acting in the (additional) role of the anonymous SOAP actor. The roles assumed MUST be invariant during the processing of an individual SOAP message; because this specification deals only with the processing of individual SOAP messages, no statement is made regarding the possibility that a given piece of software might or might not act in varying roles when processing more than one SOAP message.

While the purpose of a SOAP actor name is to identify a SOAP node, there are no routing or message exchange semantics associated with the SOAP actor name. For example, SOAP Actors MAY be named with a URI useable to route SOAP messages to an appropriate SOAP node. Conversely, it is also appropriate to use SOAP actor roles with names that are related more indirectly to message routing (e.g. "http://example.org/banking/anyAccountMgr") or which are unrelated to routing (e.g. a URI meant to identify "all cache management software"; such a header might be used, for example, to carry an indication to any concerned software that the containing SOAP message is idempotent, and can safely be cached and replayed.)

2.3 Targeting SOAP Header Blocks

SOAP header blocks carry optional attribute information items with a local name of actor and a namespace name of http://www.w3.org/2001/06/soap-envelope (see 4.2.2 SOAP actor Attribute) that are used to target them to the appropriate SOAP node(s). SOAP header blocks with no such attribute information item and the SOAP body are implicitly targeted at the anonymous SOAP actor, implying that they are to be processed by the ultimate SOAP receiver. We refer to the (implicit or explicit) value of the SOAP actor attribute as the SOAP actor for the corresponding SOAP block (either a SOAP header block or a SOAP body block).

We say that a SOAP block is targeted to a SOAP node if the SOAP actor (if present) on the block matches (see [9]) a role played by the SOAP node, or in the case of a SOAP block with no actor attribute information item (including SOAP body blocks), if the SOAP node has assumed the role of the anonymous SOAP actor.

2.5 Processing SOAP Messages

This section sets out the rules by which SOAP messages are processed. Unless otherwise stated, processing must be semantically equivalent to performing the following steps separately, and in the order given. Note however that nothing in this specification should be taken to prevent the use of optimistic concurrency, roll back, or other techniques that might provide increased flexibility in processing order as long as all SOAP messages, SOAP faults and application-level side effects are equivalent to those that would be obtained by direct implementation of the following rules.

  1. Generate a single SOAP MustUnderstand fault (see 4.4.2 MustUnderstand Faults) if one or more SOAP blocks targeted at the SOAP node are mandatory and are not understood by that node. If such a fault is generated, any further processing MUST NOT be done.

  2. Process SOAP blocks targeted at the SOAP node, generating SOAP faults (see 4.4 SOAP Fault if necessary. A SOAP node MUST process SOAP blocks identified as mandatory. A SOAP node MAY process or ignore SOAP blocks not so identified. In all cases where a SOAP block is processed, the SOAP node must understand the SOAP block and must do such processing in a manner fully conformant with the specification for that SOAP block. Faults, if any, must also conform to the specification for the processed SOAP block. It is possible that the processing of particular SOAP block would control or determine the order of processing for other SOAP blocks. For example, one could create a SOAP header block to force processing of other SOAP header blocks in lexical order. In the absence of such a SOAP block, the order of processing is at the discretion of the SOAP node. SOAP nodes can make reference to any information in the SOAP envelope when processing a SOAP block. For example, a caching function can cache the entire SOAP message, if desired.

If the SOAP node is a SOAP intermediary, the SOAP message pattern and results of processing (e.g. no fault generated) MAY require that the SOAP message be sent further along the SOAP message path. Such relayed SOAP messages MUST contain all SOAP header blocks and the SOAP body blocks from the original SOAP message, in the original order, except that SOAP header blocks targeted at the SOAP intermediary MUST be removed (such SOAP blocks are removed regardless of whether they were processed or ignored). Additional SOAP header blocks MAY be inserted at any point in the SOAP message, and such inserted SOAP header blocks MAY be indistinguishable from one or more just removed (effectively leaving them in place, but emphasizing the need to reinterpret at each SOAP node along the SOAP message path.)

3 Relation to XML

All SOAP messages have an XML Information Set[13]

A SOAP node MUST ensure that all element information items and attribute information items in messages that it generates are correctly namespace qualified. A SOAP node MUST be able to process SOAP namespace information in messages that it receives. It MUST discard messages that have incorrect namespace information (see 4.4 SOAP Fault)

SOAP defines the following namespaces[9]:

Schema documents for these namespaces can be found by dereferencing the namespace identifiers.

A SOAP message MUST NOT contain a Document Type Declaration. A SOAP message MUST NOT contain processing instruction information items[10].

SOAP uses unqualified attribute information items with a local name of id and a type of ID in the http://www.w3.org/2001/XMLSchema namespace to specify the unique identifier of an encoded element. SOAP uses unqualified attribute information items with a local name of href and a type of anyURI in the http://www.w3.org/2001/XMLSchema namespace to specify a reference to such a value, in a manner conforming to the XML Specification[10], XML Schema Specification[7], and XML Linking Language Specification[11].

A SOAP message MUST NOT impose any XML schema processing (assessment and validation) requirement on the part of any receiving SOAP node. Therefore, SOAP REQUIRES that all attribute information items, whether specified in this specification or whether they belong to a foreign namespace be carried in the serialized SOAP envelope.

4 SOAP Envelope

A SOAP message has an XML Infoset that consists of a document information item with exactly one child, which is an element information item as described below.

The document element information item has:

4.1 Envelope Encoding and Versioning

4.1.1 SOAP encodingStyle Attribute

SOAP defines an encodingStyle attribute information item which can be used to indicate the encoding rules used to serialize a SOAP message.

The encodingStyle attribute information item has:

  • A local name of encodingStyle

  • A namespace name of http://www.w3.org/2001/06/soap-envelope

Editorial note: MJG20010802
The following sentence conflicts with the definition of the Body

It may appear on any element information item in the SOAP message. Its scope is that of its owner element information item and that element information item's descendants, unless a descendant itself owns such an attribute information item.

The encodingStyle attribute information item is a whitespace delimited list where each item in the list is of type anyURI in the namespace http://www.w3.org/2001/XMLSchema. Each item in the list identifies a set of serialization rules that can be used to deserialize the SOAP message. The sets of rules should be listed in the order most specific to least specific.

Example: Example values for the encodingStyle attribute
encodingStyle="http://www.w3.org/2001/06/soap-encoding"
encodingStyle="http://example.org/encoding/restricted http://example.org/encoding/"
encodingStyle=""

The serialization rules defined by SOAP (see 5 SOAP Encoding are identified by the URI "http://www.w3.org/2001/06/soap-encoding". SOAP messages using this particular serialization SHOULD indicate this using the SOAP encodingStyle attribute information item. In addition, all URIs syntactically beginning with "http://www.w3.org/2001/06/soap-encoding" indicate conformance with the SOAP encoding rules defined in 5 SOAP Encoding (though with potentially tighter rules added).

A value of the zero-length URI ("") explicitly indicates that no claims are made for the encoding style of contained elements. This can be used to turn off any claims from containing elements.

4.2 SOAP Header

SOAP provides a flexible mechanism for extending a SOAP message in a decentralized and modular way without prior knowledge between the communicating parties. Typical examples of extensions that can be implemented as SOAP header blocks are authentication, transaction management, payment, etc.

The Header element information item has:

  • A local name of Header

  • A namespace name of http://www.w3.org/2001/06/soap-envelope

  • Zero or more namespace qualified attribute information item children.

  • Zero or more namespace qualified element information item children.

All child element information items of the SOAP Header are called SOAP header blocks.

Each SOAP header block element information item:

  • MUST be namespace qualified;

  • MAY have an encodingStyle attribute information item

  • MAY have an actor attribute information item

  • MAY have a mustUnderstand attribute information item

4.2.1 Use of Header Attributes

The SOAP header block attribute information items defined in this section determine how a SOAP receiver should process an incoming SOAP message, as described in 2 The SOAP Message Exchange Model. A SOAP sender generating a SOAP message SHOULD only use the SOAP header block attribute information items on child element information items of the SOAP Header element information item. A SOAP receiver MUST ignore all SOAP header block attribute information items that are applied to other descendant element information items of the SOAP Header element information item.

Example: Example header with a single header block
<env:Header xmlns:env="http://www.w3.org/2001/06/soap-envelope" >
  <t:Transaction xmlns:t="http://example.org/2001/06/tx" env:mustUnderstand="1" >
    5
  </t:Transaction>
</env:Header>

SOAP header block attribute information items MUST appear in the SOAP message itself in order to be effective; default values which may be specified in an XML Schema or other description language do not affect SOAP processing (see 3 Relation to XML).

4.2.2 SOAP actor Attribute

As described in 2 The SOAP Message Exchange Model, not all parts of a SOAP message may be intended for the ultimate SOAP receiver. SOAP defines an actor attribute information item that can be used to indicate the SOAP node at which a particular SOAP header block is targeted.

The actor attribute information item has the following Infoset properties:

  • A local name of actor;

  • A namespace name of http://www.w3.org/2001/06/soap-envelope;

  • A specified property with a value of true.

The type of the actor attribute information item is anyURI in the namespace http://www.w3.org/2001/XMLSchema . The value of the actor attribute information item is a URI that names a role that a SOAP node may assume.

At a SOAP receiver, the special URI "http://www.w3.org/2001/06/soap-envelope/actor/next" indicates that the SOAP header block is targetted at the current SOAP node. This is similar to the hop-by-hop scope model represented by the Connection header field in HTTP. Blocks marked with this special actor URI are subject to the same processing rules, outlined in 2 The SOAP Message Exchange Model, as user defined URIs.

Omitting the SOAP actor attribute information item implicitly targets the SOAP header block at the ultimate SOAP receiver.

4.2.3 SOAP mustUnderstand Attribute

As described in 2.4 Understanding SOAP Headers, the SOAP mustUnderstand attribute information item is used to indicate whether the processing of a SOAP header block is mandatory or optional at the target SOAP node.

The mustUnderstand attribute information item has the following Infoset properties:

  • A local name of mustUnderstand;

  • A namespace name of http://www.w3.org/2001/06/soap-envelope;

  • A specified property with a value of true.

The type of the mustUnderstand attribute information item is boolean in the namespace http://www.w3.org/2001/XMLSchema. Omitting this attribute information item is defined as being semantically equivalent to including it with a value of "false".

The SOAP mustUnderstand attribute information item allows for robust evolution of SOAP itself, of related services such as security mechanisms, and of applications using SOAP. SOAP blocks tagged with a SOAP mustUnderstand attribute information item with a value of "true" MUST be presumed to somehow modify the semantics of their parent or peer element information items. Tagging SOAP blocks in this manner assures that this change in semantics will not be silently (and, presumably, erroneously) ignored by those who may not fully understand it. Specific rules for processing header blocks with mustUnderstand attribute information items are provided in 2.4 Understanding SOAP Headers and 2.5 Processing SOAP Messages.

The SOAP mustUnderstand attribute is useful for detecting situations in which a SOAP block targetted at a node is not understood (see 2.4 Understanding SOAP Headers) by that node; it is not intended as a mechanism for detecting errors in routing, misidentification of nodes, failure of a node to serve in its intended role(s), etc. any of which may result in a failure to even attempt processing of a given header block. For that reason, this specification does not require any fault to be generated based on the presence or value of the mustUnderstand attribute information item on a header block not targeted to the processing node. Processors SHOULD NOT generate such faults, and this specification includes no standard representation for such a fault. This rule applies to the endpoint as well as to intermediaries; it is not in general an error for a mustUnderstand header block targeted to a node other than the endpoint to reach the endpoint without having been processed.

Note:

SOAP extensions can be defined for indicating the order in which processing is to occur, and for generating faults when a header entry is not processed in the appropriate order. Specifically, it is possible to create SOAP header blocks which are themselves targeted to the endpoint (or intermediaries), have a mustUnderstand attribute information item with a value of "true", and which have as their semantic a requirement to generate some particular fault if other headers have inadvertently survived past the intended point in the message path message (presumably due to a failure to reach the intended processing node earlier in the path). Such extensions MAY depend on the presence or value of the mustUnderstand attribute information item in the surviving headers when determining whether an error has occurred.

4.4 SOAP Fault

The SOAP Fault element information item is used to carry error and/or status information within a SOAP message. If present, the SOAP Fault MUST appear as a SOAP body block and MUST NOT appear more than once within a SOAP Body.

The Fault element information item has:

  • A local name of Fault;

  • A namespace name of http://www.w3.org/2001/06/soap-envelope;

  • Two or more child element information items in order as follows:

    1. A mandatory faultcode element information item as described below;

    2. A mandatory faultstring element information item as described below;

    3. An optional faultactor element information item as described below;

    4. An optional detail element information item as described below.

The faultcode element information item has:

  • A local name of faultcode

  • A namespace name which is empty

The type of the faultcode element information item is QName in the http://www.w3.org/2001/XMLSchema namespace. It is intended for use by software to provide an algorithmic mechanism for identifying the fault. SOAP defines a small set of SOAP fault codes covering basic SOAP faults (see 4.4.1 SOAP Fault Codes)

The faultstring element information item has:

  • A local name of faultstring;

  • A namespace name which is empty.

The type of the faultstring element information item is string in the http://www.w3.org/2001/XMLSchema namespace. It is intended to provide a human readable explanation of the fault and is not intended for algorithmic processing. This element information item is similar to the 'Reason-Phrase' defined by HTTP[4] and SHOULD provide at least some information explaining the nature of the fault.

The faultactor element information item has:

  • A local name of faultactor

  • A namespace name which is empty

The type of the faultactor element information item is anyURI in the http://www.w3.org/2001/XMLSchema namespace. It is intended to provide information about which SOAP node on the SOAP message path caused the fault to happen (see 2 The SOAP Message Exchange Model). It is similar to the SOAP actor attribute information item (see 4.2.2 SOAP actor Attribute) but instead of indicating the target of a SOAP header block, it indicates the source of the fault. The value of the faultactor element information item identifies the source of the fault. SOAP nodes that do not act as the ultimate SOAP receiver MUST include this element information item The ultimate SOAP receiver MAY include this element information item to indicate explicitly that it generated the fault.

The detail element information item has:

  • A local name of detail;

  • A namespace name which is empty;

  • Zero or more attribute information items;

  • Zero or more child element information items.

The detail element information item is intended for carrying application specific error information related to the SOAP Body. It MUST be present when the contents of the SOAP Body could not be processed successfully . It MUST NOT be used to carry error information about any SOAP header blocks. Detailed error information for SOAP header blocks MUST be carried within the SOAP header blocks themselves.

The absence of the detail element information item indicates that a SOAP Fault is not related to the processing of the SOAP Body. This can be used to find out whether the SOAP Body was at least partially processed by the ultimate SOAP receiver before the fault occurred, or not.

All child element information items of the detail element Information Item are called detail entries.

Each such element information item:

  • MAY be namespace qualified;

  • MAY have an encodingStyle attribute information item.

The SOAP encodingStyle attribute information item is used to indicate the encoding style used for the detail entries (see 4.1.1 SOAP encodingStyle Attribute).

4.4.1 SOAP Fault Codes

Editorial note: MJH20010810
The following paragraph seems to be contradicted by the rules in 7.3 RPC Faults. Specifically, a new namespace is used and new codes are introduced.

The SOAP faultcode values defined in this section MUST be used as values for the SOAP faultcode element information item when describing faults defined by this specification. The namespace identifier for these SOAP faultcode values is "http://www.w3.org/2001/06/soap-envelope". Use of this namespace is recommended (but not required) in the specification of methods defined outside of the present specification.

SOAP faultcode values are defined in an extensible manner that allows for new SOAP faultcode values to be defined while maintaining backwards compatibility with existing SOAP faultcode values. The mechanism used is very similar to the 1xx, 2xx, 3xx etc basic status classes classes defined in HTTP (see [4] section 10). However, instead of integers, they are defined as XML qualified names[9]. The character "." (dot) is used as a separator of SOAP faultcode values indicating that what is to the left of the dot is a more generic fault code value than the value to the right. This is illustrated in the following example.

Example: Sample authentication fault code
Client.Authentication

The faultcode values defined by SOAP are listed in the following table.

Name Meaning
VersionMismatch The processing party found an invalid namespace for the SOAP Envelope element information item (see 4.1.2 Envelope Versioning Model)
MustUnderstand An immediate child element information item of the SOAP Header element information item that was either not understood or not obeyed by the processing party contained a SOAP mustUnderstand attribute information item with a value of "true" (see 4.2.3 SOAP mustUnderstand Attribute)
DataEncodingUnknown A header or body block targetted at the current SOAP node is scoped ( See 4.1.1 SOAP encodingStyle Attribute) with a data encoding that the current node does not support.
Client The Client class of errors indicate that the message was incorrectly formed or did not contain the appropriate information in order to succeed. For example, the message could lack the proper authentication or payment information. It is generally an indication that the message should not be resent without change. See also 4.4 SOAP Fault for a description of the SOAP fault detail sub-element.
Server The Server class of errors indicate that the message could not be processed for reasons not directly attributable to the contents of the message itself but rather to the processing of the message. For example, processing could include communicating with an upstream SOAP node, which did not respond. The message may succeed at a later point in time. See also 4.4 SOAP Fault for a description of the SOAP fault detail sub-element.

4.4.2 MustUnderstand Faults

When a SOAP node generates a MustUnderstand fault, it SHOULD provide, in the generated fault message, header blocks as described below which detail the qualified names (QNames, per the XML Schema Datatypes specification[7]) of the particular header block(s) which were not understood.

Each such header block element information item has:

  • A local name of Misunderstood;

  • A namespace name of http://www.w3.org/2001/06/soap-faults;

  • A qname attribute information item as desribed below.

The qname attribute information item has the following Infoset properties:

  • A local name of qname;

  • A namespace name which is empty;

  • A specified property with a value of true.

The type of the qname attribute information item is QName in the http://www.w3.org/2001/XMLSchema namespace. Its value is the QName of a header block which the faulting node failed to understand.

Consider the following message:

Example: SOAP envelope that will cause a SOAP MustUnderstand fault if Extension1 or Extension2 are not understood
<env:Envelope xmlns:env='http://www.w3.org/2001/06/soap-envelope'>
  <env:Header>
    <abc:Extension1 xmlns:abc='http://example.org/2001/06/ext'
                       env:mustUnderstand='1' />
    <def:Extension2 xmlns:def='http://example.com/stuff'
                       env:mustUnderstand='1' />
  </env:Header>
  <env:Body>
  . . .
  </env:Body>
</env:Envelope>

The above message would result in the fault message shown below if the recipient of the initial message does not understand the two header elements abc:Extension1 and def:Extension2.

Example: SOAP fault generated as a result of not understanding Extension1 and Extension2
<env:Envelope xmlns:env='http://www.w3.org/2001/06/soap-envelope'
                      xmlns:f='http://www.w3.org/2001/06/soap-faults' >
  <env:Header>
    <f:Misunderstood qname='abc:Extension1'
                                xmlns:abc='http://example.org/2001/06/ext' />
    <f:Misunderstood qname='def:Extension2'
                                xmlns:def='http://example.com/stuff' />
  </env:Header>
  <env:Body>
    <env:Fault>
      <faultcode>MustUnderstand</faultcode>
      <faultstring>One or more mandatory headers not understood</faultstring>
    </env:Fault>
  </env:Body>
</env:Envelope>

Note that when serializing the qname attribute information item there must be an in-scope namespace declaration for the namespace name of the misunderstood header and the value of the attribute information item must use the prefix of such a namespace declaration

Note also that there is no guarantee that each MustUnderstand error contains ALL misunderstood header QNames. SOAP nodes MAY generate a fault after the first header block that causes an error containing details about that single header block only, alternatively SOAP nodes MAY generate a combined fault detailing all of the MustUnderstand problems at once.

5 SOAP Encoding

The SOAP encoding style is based on a simple type system that is a generalization of the common features found in type systems in programming languages, databases and semi-structured data. A type either is a simple (scalar) type or is a compound type constructed as a composite of several parts, each with a type. This is described in more detail below. This section defines rules for serialization of a graph of typed objects. It operates on two levels. First, given a schema in any notation consistent with the type system described, a schema for an XML grammar may be constructed. Second, given a type-system schema and a particular graph of values conforming to that schema, an XML instance may be constructed. In reverse, given an XML instance produced in accordance with these rules, and given also the original schema, a copy of the original value graph may be constructed.

The namespace identifier for the elements and attributes defined in this section is "http://www.w3.org/2001/06/soap-encoding". The encoding samples shown assume all namespace declarations are at a higher element level.

Use of the data model and encoding style described in this section is encouraged but not required; other data models and encodings can be used in conjunction with SOAP (see 4.1.1 SOAP encodingStyle Attribute).

5.1 Rules for Encoding Types in XML

XML allows very flexible encoding of data. SOAP defines a narrower set of rules for encoding. This section defines the encoding rules at a high level, and the next section describes the encoding rules for specific types when they require more detail. The encodings described in this section can be used in conjunction with the mapping of RPC calls and responses specified in 7 Using SOAP for RPC.

To describe encoding, the following terminology is used:

  1. A "value" is a string, the name of a measurement (number, date, enumeration, etc.) or a composite of several such primitive values. All values are of specific types.

  2. A "simple value" is one without named parts. Examples of simple values are particular strings, integers, enumerated values etc.

  3. A "compound value" is an aggregate of relations to other values. Examples of Compound Values are particular purchase orders, stock reports, street addresses, etc.

  4. Within a compound value, each related value is potentially distinguished by a role name, ordinal or both. This is called its "accessor." Examples of compound values include particular Purchase Orders, Stock Reports etc. Arrays are also compound values. It is possible to have compound values with several accessors each named the same, as for example, RDF does.

  5. An "array" is a compound value in which ordinal position serves as the only distinction among member values.

  6. A "struct" is a compound value in which accessor name is the only distinction among member values, and no accessor has the same name as any other.

  7. A "simple type" is a class of simple values. Examples of simple types are the classes called "string," "integer," enumeration classes, etc.

  8. A "compound type" is a class of compound values. An example of a compound type is the class of purchase order values sharing the same accessors (shipTo, totalCost, etc.) though with potentially different values (and perhaps further constrained by limits on certain values).

  9. Within a compound type, if an accessor has a name that is distinct within that type but is not distinct with respect to other types, that is, the name plus the type together are needed to make a unique identification, the name is called "locally scoped." If however the name is based in part on a Uniform Resource Identifier, directly or indirectly, such that the name alone is sufficient to uniquely identify the accessor irrespective of the type within which it appears, the name is called "universally scoped."

  10. Given the information in the schema relative to which a graph of values is serialized, it is possible to determine that some values can only be related by a single instance of an accessor. For others, it is not possible to make this determination. If only one accessor can reference it, a value is considered "single-reference". If referenced by more than one, actually or potentially, it is "multi-reference." Note that it is possible for a certain value to be considered "single-reference" relative to one schema and "multi-reference" relative to another.

  11. Syntactically, an element may be "independent" or "embedded." An independent element is any element appearing at the top level of a serialization. All others are embedded elements.

Although it is possible to use the xsi:type attribute such that a graph of values is self-describing both in its structure and the types of its values, the serialization rules permit that the types of values MAY be determinate only by reference to a schema. Such schemas MAY be in the notation described by "XML Schema Part 1: Structures" [6] and "XML Schema Part 2: Datatypes" [7] or MAY be in any other notation. Note also that, while the serialization rules apply to compound types other than arrays and structs, many schemas will contain only struct and array types.

The rules for serialization are as follows:

  1. All values are represented as element content. A multi-reference value MUST be represented as the content of an independent element. A single-reference value SHOULD NOT be (but MAY be).

  2. For each element containing a value, the type of the value MUST be represented by at least one of the following conditions: (a) the containing element instance contains an xsi:type attribute, (b) the containing element instance is itself contained within an element containing a (possibly defaulted) enc:arrayType attribute or (c) or the name of the element bears a definite relation to the type, that type then determinable from a schema.

  3. A simple value is represented as character data, that is, without any subelements. Every simple value must have a type that is either listed in the XML Schemas Specification, part 2[7] or whose source type is listed therein (see also 5.2 Simple Types).

  4. A Compound Value is encoded as a sequence of elements, each accessor represented by an embedded element whose name corresponds to the name of the accessor. Accessors whose names are local to their containing types have unqualified element names; all others have qualified names (see also 5.4 Compound Types).

  5. A multi-reference simple or compound value is encoded as an independent element containing a local, unqualified attribute named id and of type "ID" per the XML Specification [10]. Each accessor to this value is an empty element having a local, unqualified attribute named href and of type "uri-reference" per the XML Schema Specification[7], with a href attribute value of a URI fragment identifier referencing the corresponding independent element.

  6. Strings and byte arrays are represented as multi-reference simple types, but special rules allow them to be represented efficiently for common cases (see also 5.2.1 Strings and 5.2.3 Array of Bytes ). An accessor to a string or byte-array value MAY have an attribute named id and of type "ID" per the XML Specification[10]. If so, all other accessors to the same value are encoded as empty elements having a local, unqualified attribute named href and of type "uri-reference" per the XML Schema Specification[7], with a href attribute value of a URI fragment identifier referencing the single element containing the value.

  7. It is permissible to encode several references to a value as though these were references to several distinct values, but only when from context it is known that the meaning of the XML instance is unaltered.

  8. Arrays are compound values (see also 5.4.2 Arrays). SOAP arrays are defined as having a type of "enc:Array" or a type derived there from.

    SOAP arrays have one or more dimensions (rank) whose members are distinguished by ordinal position. An array value is represented as a series of elements reflecting the array, with members appearing in ascending ordinal sequence. For multi-dimensional arrays the dimension on the right side varies most rapidly. Each member element is named as an independent element (see rule 2/>).

    SOAP arrays can be single-reference or multi-reference values, and consequently may be represented as the content of either an embedded or independent element.

    SOAP arrays MUST contain a enc:arrayType attribute whose value specifies the type of the contained elements as well as the dimension(s) of the array. The value of the enc:arrayType attribute is defined as follows:

    Value of enc:arrayType
    [1]   arrayTypeValue   ::=   atype asize
    [2]   atype   ::=   QName *( rank )
    [3]   rank   ::=   "[" *( "," ) "]"
    [4]   asize   ::=   "[" #length "]"
    [5]   length   ::=   1*DIGIT

    The "atype" construct is the type name of the contained elements expressed as a QName as would appear in the type attribute of an XML Schema element declaration and acts as a type constraint (meaning that all values of contained elements are asserted to conform to the indicated type; that is, the type cited in enc:arrayType must be the type or a supertype of every array member). In the case of arrays of arrays or "jagged arrays", the type component is encoded as the "innermost" type name followed by a rank construct for each level of nested arrays starting from 1. Multi-dimensional arrays are encoded using a comma for each dimension starting from 1.

    The "asize" construct contains a comma separated list of zero, one, or more integers indicating the lengths of each dimension of the array. A value of zero integers indicates that no particular quantity is asserted but that the size may be determined by inspection of the actual members.

    For example, an array with 5 members of type array of integers would have an arrayTypeValue value of "int[][5]" of which the atype value is "int[]" and the asize value is "[5]". Likewise, an array with 3 members of type two-dimensional arrays of integers would have an arrayTypeValue value of "int[,][3]" of which the atype value is "int[,]" and the asize value is "[3]".

    A SOAP array member MAY contain a enc:offset attribute indicating the offset position of that item in the enclosing array. This can be used to indicate the offset position of a partially represented array (see 5.4.2.1 PartiallyTransmitted Arrays). Likewise, an array member MAY contain a enc:position attribute indicating the position of that item in the enclosing array. This can be used to describe members of sparse arrays (see 5.4.2.2 SparseArrays). The value of the enc:offset and the enc:position attribute is defined as follows:

    Value of enc:offset and enc:position
    [6]   arrayPoint   ::=   "[" #length "]"

    with offsets and positions based at 0.

  9. A NULL value or a default value MAY be represented by omission of the accessor element. A NULL value MAY also be indicated by an accessor element containing the attribute xsi:null with value "1" or possibly other application-dependent attributes and values.

Note that rule 2 allows independent elements and also elements representing the members of arrays to have names which are not identical to the type of the contained value.

5.2 Simple Types

For simple types, SOAP adopts all the types found in the section "Built-in datatypes" of the "XML Schema Part 2: Datatypes" Specification[7], both the value and lexical spaces. Examples include:

Type Example
int 58502
float 314159265358979E+1
negativeInteger -32768
string Louis "Satchmo" Armstrong

The datatypes declared in the XML Schema specification may be used directly in element schemas. Types derived from these may also be used. For example, for the following schema:

Example: Schema with simple types
<!-- schema document -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >

  <xs:element name="age" type="xs:int" />
  <xs:element name="height" type="xs:float" />
  <xs:element name="displacement" type="xs:negativeInteger" />
  <xs:element name="color" >
    <xs:simpleType base="xsd:string">
      <xs:restriction base="xs:string" >
        <xs:enumeration value="Green"/>
        <xs:enumeration value="Blue"/>
          </xs:restriction>
    </xs:simpleType>
  </xs:element>

</xs:schema>

the following elements would be valid instances:

Example: Message fragment corresponding to the preceding schema
<!-- Example instance elements -->
<age>45</age>
<height>5.9</height>
<displacement>-450</displacement>
<color>Blue</color>

All simple values MUST be encoded as the content of elements whose type is either defined in "XML Schema Part 2: Datatypes" Specification[7], or is based on a type found there by using the mechanisms provided in the XML Schema specification.

If a simple value is encoded as an independent element or member of a heterogenous array it is convenient to have an element declaration corresponding to the datatype. Because the "XML Schema Part 2: Datatypes" Specification[7] includes type definitions but does not include corresponding element declarations, the enc schema and namespace declares an element for every simple datatype. These MAY be used.

Example: Using elements declared in SOAP encoding schema
<enc:int xmlns:enc="http://www.w3.org/2001/06/soap-encoding" id="int1">45</enc:int>

5.2.1 Strings

The datatype "string" is defined in "XML Schema Part 2: Datatypes" Specification[7]. Note that this is not identical to the type called "string" in many database or programming languages, and in particular may forbid some characters those languages would permit. (Those values must be represented by using some datatype other than xsd:string.)

A string MAY be encoded as a single-reference or a multi-reference value.

The containing element of the string value MAY have an id attribute. Additional accessor elements MAY then have matching href attributes.

For example, two accessors to the same string could appear, as follows:

Example: Two accessors for the same string
<greeting id="String-0">Hello</greeting>
<salutation href="#String-0"/>

However, if the fact that both accessors reference the same instance of the string (or subtype of string) is immaterial, they may be encoded as two single-reference values as follows:

Example: Two accessors for the same string
<greeting>Hello</greeting>
<salutation>Hello</salutation>

Schema fragments for these examples could appear similar to the following:

Example: Schema for preceding example
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding" >

  <xs:import namespace="http://www.w3.org/2001/06/soap-encoding" />

  <xs:element name="greeting" type="enc:string" />
  <xs:element name="salutation" type="enc:string" />

</xs:schema>

(In this example, the type enc:string is used as the element's type as a convenient way to declare an element whose datatype is "xsd:string" and which also allows id and href attributes. See the SOAP Encoding schema for the exact definition. Schemas MAY use these declarations from the SOAP Encoding schema but are not required to.)

5.2.2 Enumerations

The "XML Schema Part 2: Datatypes" Specification[7] defines a mechanism called "enumeration." The SOAP data model adopts this mechanism directly. However, because programming and other languages often define enumeration somewhat differently, we spell-out the concept in more detail here and describe how a value that is a member of an enumerated list of possible values is to be encoded. Specifically, it is encoded as the name of the value.

"Enumeration" as a concept indicates a set of distinct names. A specific enumeration is a specific list of distinct values appropriate to the base type. For example the set of color names ("Green", "Blue", "Brown") could be defined as an enumeration based on the string built-in type. The values ("1", "3", "5") are a possible enumeration based on integer, and so on. "XML Schema Part 2: Datatypes"[7] supports enumerations for all of the simple types except for boolean. The language of "XML Schema Part 1: Structures" Specification[6] can be used to define enumeration types. If a schema is generated from another notation in which no specific base type is applicable, use "string". In the following schema example "EyeColor" is defined as a string with the possible values of "Green", "Blue", or "Brown" enumerated, and instance data is shown accordingly.

Example: Schema with enumeration
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                   xmlns:tns="http://example.org/2001/06/samples"
                   targetNamespace="http://example.org/2001/06/samples" >

  <xs:element name="EyeColor" type="tns:EyeColor" />
  <xs:simpleType name="EyeColor" >
    <xs:restriction base="xs:string" >
      <xs:enumeration value="Green" />
      <xs:enumeration value="Blue" />
      <xs:enumeration value="Brown" />
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
Example: Message fragment corresponding to the preceding schema
<p:EyeColor xmlns:p="http://example.org/2001/06/samples" >Brown</p:EyeColor>

5.2.3 Array of Bytes

An array of bytes MAY be encoded as a single-reference or a multi-reference value. The rules for an array of bytes are similar to those for a string.

In particular, the containing element of the array of bytes value MAY have an id attribute. Additional accessor elements MAY then have matching href attributes.

The recommended representation of an opaque array of bytes is the 'base64' encoding defined in XML Schemas[6][7], which uses the base64 encoding algorithm defined in MIME[14]. However, the line length restrictions that normally apply to base64 data in MIME do not apply in SOAP. A "enc:base64" subtype is supplied for use with SOAP.

Example: Image with base64 encoding
<picture xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
         xsi:type="enc:base64" >
   aG93IG5vDyBicm73biBjb3cNCg==
</picture>

5.4 Compound Types

SOAP defines types corresponding to the following structural patterns often found in programming languages:

Struct

A "struct" is a compound value in which accessor name is the only distinction among member values, and no accessor has the same name as any other.

Array

An "array" is a compound value in which ordinal position serves as the only distinction among member values.

SOAP also permits serialization of data that is neither a Struct nor an Array, for example data such as is found in a Directed-Labeled-Graph Data Model in which a single node has many distinct accessors, some of which occur more than once. SOAP serialization does not require that the underlying data model make an ordering distinction among accessors, but if such an order exists, the accessors MUST be encoded in that sequence.

5.4.1 Compound Values and References to Values

The members of a Compound Value are encoded as accessor elements. When accessors are distinguished by their name (as for example in a struct), the accessor name is used as the element name. Accessors whose names are local to their containing types have unqualified element names; all others have qualified names.

The following is an example of a struct of type "Book":

Example: Book structure
<e:Book xmlns:e="http://example.org/2001/06/books" >
   <author>Henry Ford</author>
   <preface>Prefactory text</preface>
   <intro>This is a book.</intro>
</e:Book>

And this is a schema fragment describing the above structure:

Example: Schema for Book structure
<xs:element name="Book"
            xmlns:xs='http://www.w3.org/2001/XMLSchema' >
  <xs:complexType>
    <xs:sequence>
      <xs:element name="author" type="xs:string" />
      <xs:element name="preface" type="xs:string" />
      <xs:element name="intro" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

Below is an example of a type with both simple and complex members. It shows two levels of referencing. Note that the href attribute of the Author accessor element is a reference to the value whose id attribute matches. A similar construction appears for the Address accessor element.

Example: Book with muli-reference addresses
<e:Book xmlns:e="http://example.org/2001/06/books" >
  <title>My Life and Work</title>
  <author href="#Person-1"/>
</e:Book>
<e:Person xmlns:e="http://example.org/2001/06/books"
          id="Person-1" >
  <name>Henry Ford</name>
  <address href="#Address-2"/>
</e:Person>
<e:Address xmlns:e="http://example.org/2001/06/books"
           id="Address-2" >
  <email>mailto:henryford@hotmail.com</email>
  <web>http://www.henryford.com</web>
</e:Address>

The form above is appropriate when the "Person" value and the "Address" value are multi-reference. If these were instead both single-reference, they SHOULD be embedded, as follows:

Example: Book with single-reference addresses
<e:Book xmlns:e="http://example.org/2001/06/books" >
   <title>My Life and Work</title>
   <author>
       <name>Henry Ford</name>
       <address>
          <email>mailto:henryford@hotmail.com</email>
          <web>http://www.henryford.com</web>
       </address>
   </author>
</e:Book>

If instead there existed a restriction that no two persons can have the same address in a given instance and that an address can be either a Street-address or an Electronic-address, a Book with two authors would be encoded as follows:

Example: Book with two authors having different addresses
<e:Book xmlns:e="http://example.org/2001/06/books" >
   <title>My Life and Work</title>
   <firstauthor href="#Person-1"/>
   <secondauthor href="#Person-2"/>
</e:Book>
<e:Person xmlns:e="http://example.org/2001/06/books"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          id="Person-1" >
   <name>Henry Ford</name>
   <address xsi:type="e:ElectronicAddressType">
       <email>mailto:henryford@hotmail.com</email>
       <web>http://www.henryford.com</web>
   </address>
</e:Person>
<e:Person xmlns:e="http://example.org/2001/06/books"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          id="Person-2">
   <name>Samuel Crowther</name>
   <address xsi:type="e:StreetAddressType">
       <street>Martin Luther King Rd</street>
       <city>Raleigh</city>
       <state>North Carolina</state>
   </address>
</e:Person>

Serializations can contain references to values not in the same resource:

Example: Book with external references
<e:Book xmlns:e="http://example.org/2001/06/books" >
   <title>Paradise Lost</title>
   <firstAuthor href="http://www.dartmouth.edu/~milton/" />
</e:Book>

And this is a schema fragment describing the above structures:

Example: Schema for preceding example
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.org/2001/06/books"
                   targetNamespace="http://example.org/2001/06/books" >

  <xs:element name="Book" type="tns:BookType" />
  <xs:complexType name="BookType" >
    <xs:annotation>
          <xs:documentation>
            <info>
        Either the following group must occur or else the
        href attribute must appear, but not both.
                </info>
          </xs:documentation>
    </xs:annotation>
    <xs:sequence minOccurs="0" maxOccurs="1" >
      <xs:element name="title" type="xs:string" />
      <xs:element name="firstAuthor" type="tns:PersonType" />
      <xs:element name="secondAuthor" type="tns:PersonType" />
    </xs:sequence>
    <xs:attribute name="href" type="xs:anyURI" />
    <xs:attribute name="id" type="xs:ID" />
    <xs:anyAttribute namespace="##other" />
  </xs:complexType>

  <xs:element name="Person" type="tns:PersonType" />
  <xs:complexType name="PersonType" >
    <xs:annotation>
          <xs:documentation>
            <info>
        Either the following group must occur or else the
        href attribute must appear, but not both.
                </info>
          </xs:documentation>
        </xs:annotation>
    <xs:sequence minOccurs="0" maxOccurs="1" >
      <xs:element name="name" type="xs:string" />
      <xs:element name="address" type="tns:AddressType" />
    </xs:sequence>
    <xs:attribute name="href" type="xs:anyURI" />
    <xs:attribute name="id" type="xs:ID" />
    <xs:anyAttribute namespace="##other" />
  </xs:complexType>

  <xs:element name="Address" base="tns:AddressType" />
  <xs:complexType name="AddressType" abstract="true" >
    <xs:annotation>
          <xs:documentation>
            <info>
        Either one of the following sequences must occur or
                else the href attribute must appear, but not both.
                </info>
          </xs:documentation>
        </xs:annotation>
    <xs:choice>
          <xs:sequence minOccurs="0" maxOccurs="1" >
            <xs:element name="email" type="xs:string" />
                <xs:element name="web" type="xs:anyURI" />
          </xs:sequence>
          <xs:sequence minOccurs='0' maxOccurs='1' >
        <xs:element name="street" type="xs:string" />
        <xs:element name="city" type="xs:string" />
        <xs:element name="state" type="xs:string"/>
          </xs:sequence>
        </xs:choice>
    <xs:attribute name="href" type="xs:anyURI"/>
    <xs:attribute name="id" type="xs:ID"/>
    <xs:anyAttribute namespace="##other"/>
  </xs:complexType>

  <xs:complexType name="StreetAddressType">
    <xs:annotation>
          <xs:documentation>
            <info>
        Either the second sequence in the following group
                must occur or else the href attribute must appear,
                but not both.
                </info>
          </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
          <xs:restriction base="tns:AddressType" >
            <xs:sequence>
              <xs:sequence minOccurs="0" maxOccurs="0" >
                <xs:element name="email" type="xs:string" />
                    <xs:element name="web" type="xs:anyURI" />
              </xs:sequence>
          <xs:sequence minOccurs="0" maxOccurs="1">
            <xs:element name="street" type="xs:string" />
            <xs:element name="city" type="xs:string" />
            <xs:element name="state" type="xs:string"/>
          </xs:sequence>
                </xs:sequence>
        <xs:attribute name="href" type="xs:anyURI"/>
        <xs:attribute name="id" type="xs:ID"/>
        <xs:anyAttribute namespace="##other"/>
          </xs:restriction>
        </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="ElectronicAddressType">
    <xs:annotation>
          <xs:documentation>
            <info>
        Either the first sequence in the following group
                must occur or else the href attribute must appear,
                but not both.
                </info>
          </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
          <xs:restriction base="tns:AddressType" >
            <xs:sequence>
          <xs:sequence minOccurs="0" maxOccurs="1">
            <xs:element name="email" type="xs:string" />
            <xs:element name="web" type="xs:anyURI" />
          </xs:sequence>
                  <xs:sequence minOccurs="0" maxOccurs="0">
            <xs:element name="street" type="xs:string" />
            <xs:element name="city" type="xs:string" />
            <xs:element name="state" type="xs:string"/>
          </xs:sequence>
                </xs:sequence>
            <xs:attribute name="href" type="xs:anyURI"/>
        <xs:attribute name="id" type="xs:ID"/>
        <xs:anyAttribute namespace="##other"/>
          </xs:restriction>
        </xs:complexContent>
  </xs:complexType>

</xs:schema>

5.4.2 Arrays

SOAP arrays are defined as having a type of enc:Array or a derived type having that type in its derivation hierarchy (see also rule 8 in 5.1 Rules for Encoding Types in XML). Such derived types would be restrictions of the enc:Array type and could be used to represent, for example, arrays limited to integers or arrays of some user-defined enumeration. Arrays are represented as element values, with no specific constraint on the name of the containing element (just as values generally do not constrain the name of their containing element). The elements which make up the array can themselves can be of any type, including nested arrays.

The representation of the value of an array is an ordered sequence of elements constituting the items of the array. Within an array value, element names are not significant for distinguishing accessors. Elements may have any name. In practice, elements will frequently be named so that their declaration in a schema suggests or determines their type. As with compound types generally, if the value of an item in the array is a single-reference value, the item contains its value. Otherwise, the item references its value via an href attribute.

The following example is a schema fragment and an array containing integer array members:

Example: Schema declaring an array of integers
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding" >
  <xs:import namespace="http://www.w3.org/2001/06/soap-encoding" />
  <xs:element name="myFavoriteNumbers" type="enc:Array" />
</xs:schema>
Example: Array conforming to the preceding schema
<myFavoriteNumbers xmlns:xs="http://www.w3.org/2001/XMLSchema"
                   xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
                   enc:arrayType="xs:int[2]" >
  <number>3</number>
  <number>4</number>
</myFavoriteNumbers>

In the preceding example, the array myFavoriteNumbers contains several members each of which is a value of type xs:int. This can be determined by inspection of the enc:arrayType attribute. Note that the enc:Array type allows both unqualified element names and qualified element names from any namespace. These convey no type information, so when used they must either have an xsi:type attribute or the containing element must have a enc:arrayType attribute. Naturally, types derived from enc:Array may declare local elements, with type information.

As previously noted, the enc schema contains declarations of elements with names corresponding to each simple type in the "XML Schema Part 2: Datatypes" Specification[7]. It also contains a declaration for Array. Using these, we might write:

Example: Using the enc:Array element
<enc:Array xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           enc:ArrayType="xs:int[2]" >
  <enc:int>3</enc:int>
  <enc:int>4</enc:int>
</enc:Array>

Arrays can contain instances of any subtype of the specified arrayType. That is, the members may be of any type that is substitutable for the type specified in the arrayType attribute, according to whatever substitutability rules are expressed in the schema. So, for example, an array of integers can contain any type derived from integer (for example "int" or any user-defined derivation of integer). Similarly, an array of "address" might contain a restricted or extended type such as "internationalAddress". Because the supplied enc:Array type admits members of any type, arbitrary mixtures of types can be contained unless specifically limited by use of the arrayType attribute.

Types of member elements can be specified using the xsi:type attribute in the instance, or by declarations in the schema of the member elements, as the following two arrays demonstrate respectively:

Example: Array with elements of varying types
<enc:Array xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           enc:arrayType="xs:anyType[4]">
   <thing xsi:type="xs:int">12345</thing>
   <thing xsi:type="xs:decimal">6.789</thing>
   <thing xsi:type="xs:string">
      Of Mans First Disobedience, and the Fruit
      Of that Forbidden Tree, whose mortal tast
      Brought Death into the World, and all our woe,
   </thing>
   <thing xsi:type="xs:anyURI">
      http://www.dartmouth.edu/~milton/reading_room/
   </thing>
</enc:Array>
Example: Array with elements of varying types
<enc:Array xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           enc:arrayType="xs:anyType[4]" >
   <enc:int>12345</enc:int>
   <enc:decimal>6.789</enc:decimal>
   <enc:string>
      Of Mans First Disobedience, and the Fruit
      Of that Forbidden Tree, whose mortal tast
      Brought Death into the World, and all our woe,
   </enc:string>
   <enc:anyURI>
      http://www.dartmouth.edu/~milton/reading_room/
   </enc:anyURI >
</enc:Array>

Array values may be structs or other compound values. For example an array of "xyz:Order" structs :

Example: Arrays containing structs and other compound values
<enc:Array xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           xmlns:xyz="http://example.org/2001/06/Orders"
           enc:arrayType="xyz:Order[2]">
   <Order>
       <Product>Apple</Product>
       <Price>1.56</Price>
   </Order>
   <Order>
       <Product>Peach</Product>
       <Price>1.48</Price>
   </Order>
</enc:Array>

Arrays may have other arrays as member values. The following is an example of an array of two arrays, each of which is an array of strings.

Example: Array containing other arrays
<enc:Array xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           enc:arrayType="xs:string[][2]" >
   <item href="#array-1"/>
   <item href="#array-2"/>
</enc:Array>
<enc:Array xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           id="array-1"
           enc:arrayType="xs:string[2]">
   <item>r1c1</item>
   <item>r1c2</item>
   <item>r1c3</item>
</enc:Array>
<enc:Array xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           id="array-2"
           enc:arrayType="xs:string[2]">
   <item>r2c1</item>
   <item>r2c2</item>
</enc:Array>

The element containing an array value does not need to be named "enc:Array". It may have any name, provided that the type of the element is either enc:Array or is derived from enc:Array by restriction. For example, the following is a fragment of a schema and a conforming instance array:

Example: Schema for an array
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           xmlns:tns="http://example.org/2001/06/numbers"
           targetNamespace="http://example.org/2001/06/numbers" >

  <xs:simpleType name="phoneNumberType" >
    <xs:restriction base="xs:string" />
  </xs:simpleType>

  <xs:element name="ArrayOfPhoneNumbers" type="tns:ArrayOfPhoneNumbersType" />

  <xs:complexType name="ArrayOfPhoneNumbersType" >
    <xs:complexContent>
      <xs:restriction base="enc:Array" >
            <xs:sequence>
          <xs:element name="phoneNumber" type="tns:phoneNumberType" maxOccurs="unbounded" />
            </xs:sequence>
        <xs:attributeGroup ref="enc:arrayAttributes" />
        <xs:attributeGroup ref="enc:commonAttributes" />
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

</xs:schema>
Example: Array conforming to the preceding schema
<abc:ArrayOfPhoneNumbers xmlns:abc="http://example.org/2001/06/numbers"
                         xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
                         enc:arrayType="abc:phoneNumberType[2]" >
   <phoneNumber>206-555-1212</phoneNumber>
   <phoneNumber>1-888-123-4567</phoneNumber>
</abc:ArrayOfPhoneNumbers>

Arrays may be multi-dimensional. In this case, more than one size will appear within the asize part of the arrayType attribute:

Example: Multi-dimensonal array
<enc:Array xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           enc:arrayType="xs:string[2,3]" >
   <item>r1c1</item>
   <item>r1c2</item>
   <item>r1c3</item>
   <item>r2c1</item>
   <item>r2c2</item>
   <item>r2c3</item>
</enc:Array>

While the examples above have shown arrays encoded as independent elements, array values MAY also appear embedded and SHOULD do so when they are known to be single reference.

The following is an example of a schema fragment and an array of phone numbers embedded in a struct of type "Person" and accessed through the accessor "phone-numbers":

Example: Schema fragment for array of phone numbers embedded in a struct
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           xmlns:tns="http://example.org/2001/06/numbers"
                   targetNamespace="http://example.org/2001/06/numbers" >

  <xs:import namespace="http://www.w3.org/2001/06/soap-encoding" />

  <xs:simpleType name="phoneNumberType" >
    <xs:restriction base="xs:string" />
  </xs:simpleType>


  <xs:element name="ArrayOfPhoneNumbers" type="tns:ArrayOfPhoneNumbersType" />

  <xs:complexType name="ArrayOfPhoneNumbersType" >
    <xs:complexContent>
      <xs:restriction base="enc:Array" >
            <xs:sequence>
          <xs:element name="phoneNumber" type="tns:phoneNumberType" maxOccurs="unbounded" />
            </xs:sequence>
        <xs:attributeGroup ref="enc:arrayAttributes" />
        <xs:attributeGroup ref="enc:commonAttributes" />
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:element name="Person">
    <xs:complexType>
          <xs:sequence>
        <xs:element name="name" type="xs:string" />
        <xs:element name="phoneNumbers" type="tns:ArrayOfPhoneNumbersType" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
Example: Array of phone numbers embedded in a struct conforming to the preceding schema
<def:Person xmlns:def="http://example.org/2001/06/numbers"
            xmlns:enc="http://www.w3.org/2001/06/soap-encoding" >
   <name>John Hancock</name>
   <phoneNumbers enc:arrayType="def:phoneNumber[2]">
       <phoneNumber>206-555-1212</phoneNumber>
       <phoneNumber>1-888-123-4567</phoneNumber>
   </phoneNumbers>
</def:Person>

Here is another example of a single-reference array value encoded as an embedded element whose containing element name is the accessor name:

Example: Single-reference array encoded as en embedded element
<xyz:PurchaseOrder xmlns:xyz="http://example.org/2001/06/Orders" >
   <CustomerName>Henry Ford</CustomerName>
   <ShipTo>
       <Street>5th Ave</Street>
       <City>New York</City>
       <State>NY</State>
       <Zip>10010</Zip>
   </ShipTo>
   <PurchaseLineItems xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
                      enc:arrayType="xyz:Order[2]">
       <Order>
           <Product>Apple</Product>
           <Price>1.56</Price>
       </Order>
       <Order>
           <Product>Peach</Product>
           <Price>1.48</Price>
       </Order>
   </PurchaseLineItems>
</xyz:PurchaseOrder>
5.4.2.1 PartiallyTransmitted Arrays

SOAP provides support for partially transmitted arrays, known as "varying" arrays in some contexts[7]. A partially transmitted array indicates in an enc:offset attribute the zero-origin offset of the first element transmitted. If omitted, the offset is taken as zero.

The following is an example of an array of size five that transmits only the third and fourth element counting from zero:

Example: Array of size five that transmits only the third and fourth element
<enc:Array xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           enc:arrayType="xs:string[6]"
           enc:offset="[3]" >
  <item>The fourth element</item>
  <item>The fifth element</item>
</enc:Array>

5.4.3 Generic Compound Types

The encoding rules just cited are not limited to those cases where the accessor names are known in advance. If accessor names are known only by inspection of the immediate values to be encoded, the same rules apply, namely that the accessor is encoded as an element whose name matches the name of the accessor, and the accessor either contains or references its value. Accessors containing values whose types cannot be determined in advance MUST always contain an appropriate xsi:type attribute giving the type of the value.

Similarly, the rules cited are sufficient to allow serialization of compound types having a mixture of accessors distinguished by name and accessors distinguished by both name and ordinal position. (That is, having some accessors repeated.) This does not require that any schema actually contain such types, but rather says that if a type-model schema does have such types, a corresponding XML syntactic schema and instance may be generated.

Example: Generic compound types
<xyz:PurchaseOrder xmlns:xyz="http://example.org/2001/06/Orders" >
  <CustomerName>Henry Ford</CustomerName>
  <ShipTo>
    <Street>5th Ave</Street>
    <City>New York</City>
    <State>NY</State>
    <Zip>10010</Zip>
  </ShipTo>
  <PurchaseLineItems>
    <Order>
      <Product>Apple</Product>
      <Price>1.56</Price>
    </Order>
    <Order>
      <Product>Peach</Product>
      <Price>1.48</Price>
    </Order>
  </PurchaseLineItems>
</xyz:PurchaseOrder>

Similarly, it is valid to serialize a compound value that structurally resembles an array but is not of type (or subtype) enc:Array. For example:

Example: Compound value
<PurchaseLineItems>
    <Order>
        <Product>Apple</Product>
        <Price>1.56</Price>
    </Order>
    <Order>
        <Product>Peach</Product>
        <Price>1.48</Price>
    </Order>
</PurchaseLineItems>

6 Using SOAP in HTTP

This section describes how to use SOAP within HTTP. Binding SOAP to HTTP provides the advantage of being able to use the formalism and decentralized flexibility of SOAP with the rich feature set of HTTP. Carrying SOAP in HTTP does not mean that SOAP overrides existing semantics of HTTP but rather that SOAP over HTTP inherits HTTP semantics.

SOAP naturally follows the HTTP request/response message model by providing a SOAP request message in a HTTP request and SOAP response message in a HTTP response. Note, however, that SOAP intermediaries are NOT the same as HTTP intermediaries. That is, an HTTP intermediary addressed with the HTTP Connection header field cannot be expected to inspect or process the SOAP entity body carried in the HTTP request.

HTTP applications MUST use the media type "text/xml" according to RFC 2376[12] when including SOAP messages in HTTP exchanges.

7 Using SOAP for RPC

One of the design goals of SOAP is to encapsulate remote procedure call functionality using the extensibility and flexibility of XML. This section defines a uniform representation of RPC invocations and responses.

Although it is anticipated that this representation is likely to be used in combination with the encoding style defined in 5 SOAP Encoding, other representations are possible. The SOAP encodingStyle attribute (see 4.1.1 SOAP encodingStyle Attribute) can be used to indicate the encoding style of the RPC invocation and/or the response using the representation described in this section.

Using SOAP for RPC is orthogonal to the SOAP protocol binding (see 6 Using SOAP in HTTP). In the case of using HTTP as the protocol binding, an RPC invocation maps naturally to an HTTP request and an RPC response maps to an HTTP response. However, using SOAP for RPC is not limited to the HTTP protocol binding.

To invoke an RPC, the following information is needed:

SOAP relies on the protocol binding to provide a mechanism for carrying the URI. For example, for HTTP the request URI indicates the resource that the invocation is being made against. Other than it be a valid URI, SOAP places no restriction on the form of an address (see RFC2396[8] for more information on URIs).

7.1 RPC and SOAP Body

RPC invocations and responses are both carried in the SOAP Body element (see 4.3 SOAP Body) using the following representation:

  • An RPC invocation is modeled as a struct.

  • The invocation is viewed as a single struct containing an accessor for each [in] or [in/out] parameter. The struct is both named and typed identically to the procedure or method name.

  • Each [in] or [in/out] parameter is viewed as an accessor, with a name corresponding to the name of the parameter and type corresponding to the type of the parameter. These appear in the same order as in the procedure or method signature.

  • An RPC response is modeled as a struct.

  • The response is viewed as a single struct containing an accessor for the return value and each [out] or [in/out] parameter. The first accessor is the return value followed by the parameters in the same order as in the procedure or method signature.

  • Each parameter accessor has a name corresponding to the name of the parameter and type corresponding to the type of the parameter. The name of the return value accessor is not significant. Likewise, the name of the struct is not significant. However, a convention is to name it after the procedure or method name with the string "Response" appended.

  • Invocation faults are handled according to the rules in 7.3 RPC Faults. If a protocol binding adds additional rules for fault expression, those MUST also be followed.

As noted above, RPC invocation and response structs can be encoded according to the rules in 5 SOAP Encoding, or other encodings can be specified using the encodingStyle attribute (see 4.1.1 SOAP encodingStyle Attribute).

Applications MAY process invocations with missing parameters but also MAY return a fault.

Because a result indicates success and a fault indicates failure, it is an error for an RPC response to contain both a result and a fault.

7.3 RPC Faults

Editorial note: MJH20010810
The following paragraph conflicts with the first paragraph of 4.4.1 SOAP Fault Codes.

The RPC representation introduces additional SOAP fault codes to those described in 4.4.1 SOAP Fault Codes. The namespace identifier for these SOAP faultcode element information item values is "http://www.w3.org/2001/06/rpc" and the namespace prefix rpc: is used in this section to indicate association with this namespace.

Errors arising during RPC invocations are reported according to the following rules (in order of precedence):

  1. A soap-env:Server fault SHOULD be generated when the server cannot handle the message because of some temporary condition, e.g. when it is out of memory. This does not apply to temporary conditions of the application, e.g. a database being unavailable or a record not present.

  2. A soap-env:DataEncodingUnknown fault SHOULD be generated when the arguments are encoded in a data encoding unknown to the server.

  3. An rpc:ProcedureNotPresent fault MUST be generated when the server cannot find the procedure specified.

  4. An rpc:BadArguments fault MUST be generated when the server cannot parse the arguments or when there is a mismatch between what the server expects and what the client has sent.

  5. Other faults arising in an extension or from the application SHOULD be generated as described in 4.4 SOAP Fault. Procedure level errors, i.e. those that might normally be expected when executing a procedure, SHOULD be indicated in a successful RPC response containing some application-dependent indication of a failure.

In all cases the values of the detail and faultstring element information items are implementation defined. They MAY be specified by some external document.

8 Security Considerations

Not described in this document are methods for integrity and privacy protection. Such issues may be addressed in future versions of this document.

9 References

9.1 Normative References

1
XML Protocol Comments Archive (See http://lists.w3.org/Archives/Public/xmlp-comments/.)
2
XML Protocol Discussion Archive (See http://lists.w3.org/Archives/Public/xml-dist-app/.)
3
XML Protocol Charter (See http://www.w3.org/2000/09/XML-Protocol-Charter.)
4
IETF "RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1", R. Fielding, J. Gettys, J. C. Mogul, H. Frystyk, T. Berners-Lee, January 1997. (See http://www.ietf.org/rfc/rfc2616.txt.)
5
IETF "RFC 2119: Key words for use in RFCs to Indicate Requirement Levels", S. Bradner, March 1997. (See http://www.ietf.org/rfc/rfc2119.txt.)
6
W3C Recommendation "XML Schema Part 1: Structures", Henry S. Thompson, David Beech, Murray Maloney, Noah Mendelsohn, 2 May 2001. (See http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/.)
7
W3C Recommendation "XML Schema Part 2: Datatypes", Paul V. Biron, Ashok Malhotra, 2 May 2001. (See http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/.)
8
IETF "RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax", T. Berners-Lee, R. Fielding, L. Masinter, August 1998. (See http://www.ietf.org/rfc/rfc2396.txt.)
9
W3C Recommendation "Namespaces in XML", Tim Bray, Dave Hollander, Andrew Layman, 14 January 1999. (See http://www.w3.org/TR/1999/REC-xml-names-19990114.)
10
W3C Recommendation "Extensible Markup Language (XML) 1.0 (Second Edition)", Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, 6 October 2000. (See http://www.w3.org/TR/2000/REC-xml-20001006.)
11
W3C Proposed Recommendation "XML Linking Language (XLink) Version 1.0", Steve DeRose, Eve Maler, David Orchard, 20 December 2000. (See http://www.w3.org/TR/2000/PR-xlink-20001220/.)
12
IETF "RFC 2376: XML Media Types", E. Whitehead, M. Murata, July 1998. (See http://www.ietf.org/rfc/rfc2376.txt.)

A Version Transition From SOAP/1.1 to SOAP Version 1.2

Editorial note20010806
The scope of the mechanism provided in this section is for transition between SOAP/1.1 and SOAP version 1.2. The Working Group is considering providing a more general transition mechanism that can apply to any version.| Such a general mechanism may or may not be the mechanism provided here depending on whether it is deemed applicable.

The SOAP/1.1 specification[15] says the following on versioning in section 4.1.2:

"SOAP does not define a traditional versioning model based on major and minor version numbers. A SOAP message MUST have an Envelope element associated with the "http://schemas.xmlsoap.org/soap/envelope/" namespace. If a message is received by a SOAP application in which the SOAP Envelope element is associated with a different namespace, the application MUST treat this as a version error and discard the message. If the message is received through a request/response protocol such as HTTP, the application MUST respond with a SOAP VersionMismatch faultcode message (see section 4.4) using the SOAP "http://schemas.xmlsoap.org/soap/envelope/" namespace."

That is, rather than a versioning model based on shortnames (typically version numbers), SOAP uses a declarative extension model which allows a sender to include the desired features within the SOAP envelope construct. SOAP says nothing about the granularity of extensions nor how extensions may or may not affect the basic SOAP processing model. It is entirely up to extension designers be it either in a central or a decentralized manner to determine which features become SOAP extensions.

The SOAP extensibility model is based on the following three basic assumptions:

  1. SOAP versioning is directed only at the SOAP envelope. It explicitly does not address versioning of blocks, encodings, protocol bindings, or otherwise.

  2. A SOAP node must determine whether it supports the version of a SOAP message on a per message basis. In the following, "support" means understanding the semantics of the envelope version identified by the QName of the Envelope element information item:

    • A SOAP node receiving an envelope that it doesn't support must not attempt to process the message according to any other processing rules regardless of other up- or downstream SOAP nodes.

    • A SOAP node may provide support for multiple envelope versions. However, when processing a message a SOAP node must use the semantics defined by the version of that message.

  3. It is essential that the envelope remains stable over time and that new features are added using the SOAP extensibility mechanism. Changing the envelope inherently affects interoperability, adds complexity, and requires central control of extensions -- all of which directly conflicts with the SOAP requirements.

The rules for dealing with the possible SOAP/1.1 and SOAP Version 1.2 interactions are as follows:

  1. Because of the SOAP/1.1 rules, a compliant SOAP/1.1 node receiving a SOAP Version 1.2 message will generate a VersionMismatch SOAP fault using an envelope qualified by the "http://schemas.xmlsoap.org/soap/envelope/" namespace identifier.

  2. A SOAP Version 1.2 node receiving a SOAP/1.1 message may either process the message as SOAP/1.1 or generate a SOAP VersionMismatch fault using the "http://schemas.xmlsoap.org/soap/envelope/" namespace identifier. As part of the SOAP VersionMismatch fault, a SOAP Version 1.2 node should include the list of envelope versions that it supports using the SOAP upgrade extension identified by the "http://www.w3.org/2001/06/soap-upgrade" identifier.

The upgrade extension contains an ordered list of namespace identifiers of SOAP envelopes that the SOAP node supports in the order most to least preferred. Following is an example of a VersionMismatch fault generated by a SOAP Version 1.2 node including the SOAP upgrade extension:

Example: VersionMismatch fault generated by a SOAP Version 1.2 node, and including a SOAP upgrade extension
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Header>
    <V:Upgrade xmlns:V="http://www.w3.org/2001/06/soap-upgrade">
      <envelope qname="ns1:Envelope" xmlns:ns1="http://www.w3.org/2001/06/soap-envelope"/>
    </V:Upgrade>
  </env:Header>
  <env:Body>
    <env:Fault>
      <faultcode>env:VersionMismatch</faultcode>
      <faultstring>Version Mismatch</faultstring>
    </env:Fault>
  </env:Body>
</env:Envelope>

Note that existing SOAP/1.1 nodes are not likely to indicate which envelope versions they support. If nothing is indicated then this means that SOAP/1.1 is the only supported envelope.

B SOAP Envelope Examples (Non-Normative)

B.2 Sample Encoding of Response

Example: SOAP message using SOAP encoding in HTTP response including a mandatory header
HTTP/1.1 200 OK
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope" >
   <env:Header>
       <t:Transaction xmlns:t="http://example.org/2001/06/tx"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      xsi:type="xs:int"
                      env:encodingStyle="http://www.w3.org/2001/06/soap-encoding"
                      env:mustUnderstand="1" >
           5
       </t:Transaction>
   </env:Header>
   <env:Body>
       <m:GetLastTradePriceResponse
             env:encodingStyle="http://www.w3.org/2001/06/soap-encoding"
             xmlns:m="http://example.org/2001/06/quotes" >
           <Price>34.5</Price>
       </m:GetLastTradePriceResponse>
   </env:Body>
</env:Envelope>
Example: Similar to previous example but using a struct for the body and ommitting the mandatory header
HTTP/1.1 200 OK
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope" >
   <env:Body>
       <m:GetLastTradePriceResponse
             env:encodingStyle="http://www.w3.org/2001/06/soap-encoding"
             xmlns:m="http://example.org/2001/06/quotes" >
           <PriceAndVolume>
               <LastTradePrice>34.5</LastTradePrice>
               <DayVolume>10000</DayVolume>
           </PriceAndVolume>
       </m:GetLastTradePriceResponse>
   </env:Body>
</env:Envelope>
Example: Must understand fault in HTTP response
HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope">
   <env:Body>
       <env:Fault>
           <faultcode>env:MustUnderstand</faultcode>
           <faultstring>SOAP Must Understand Error</faultstring>
       </env:Fault>
   </env:Body>
</env:Envelope>
Example: SOAP fault, resulting from failure to handle the SOAP body, in HTTP response
HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope" >
  <env:Body>
    <env:Fault>
      <faultcode>env:Server</faultcode>
      <faultstring>Server Error</faultstring>
      <detail>
        <e:myfaultdetails xmlns:e="http://example.org/2001/06/faults" >
          <message>My application didn't work</message>
          <errorcode>1001</errorcode>
        </e:myfaultdetails>
      </detail>
    </env:Fault>
 </env:Body>
</env:Envelope>

C Acknowledgements (Non-Normative)

This document is the work of the W3C XML Protocol Working Group.

Members of the Working Group are (at the time of writing, and by alphabetical order): Yasser al Safadi (Philips Research), Vidur Apparao (Netscape), Don Box (DevelopMentor), David Burdett (Commerce One), Charles Campbell (Informix Software), Alex Ceponkus (Bowstreet), Michael Champion (Software AG), David Clay (Oracle), Ugo Corda (Xerox), Paul Cotton (Microsoft Corporation), Ron Daniel (Interwoven), Glen Daniels (Allaire), Doug Davis (IBM), Ray Denenberg (Library of Congress), Paul Denning (MITRE Corporation), Frank DeRose (TIBCO Software, Inc.), Brian Eisenberg (Data Channel), David Ezell (Hewlett-Packard), James Falek (TIBCO Software, Inc.), David Fallside (IBM), Chris Ferris (Sun Microsystems), Daniela Florescu (Propel), Dan Frantz (BEA Systems), Dietmar Gaertner (Software AG), Scott Golubock (Epicentric), Rich Greenfield (Library of Congress), Martin Gudgin (Develop Mentor), Hugo Haas (W3C), Marc Hadley (Sun Microsystems), Mark Hale (Interwoven), Randy Hall (Intel), Gerd Hoelzing (SAP AG), Oisin Hurley (IONA Technologies), Yin-Leng Husband (Compaq), John Ibbotson (IBM), Ryuji Inoue (Matsushita Electric Industrial Co., Ltd.), Scott Isaacson (Novell, Inc.), Kazunori Iwasa (Fujitsu Software Corporation), Murali Janakiraman (Rogue Wave), Mario Jeckle (Daimler-Chrysler Research and Technology), Eric Jenkins (Engenia Software), Mark Jones (AT&T), Jay Kasi (Commerce One), Jeffrey Kay (Engenia Software), Richard Koo (Vitria Technology Inc.), Jacek Kopecky (IDOOX s.r.o.), Alan Kropp (Epicentric), Yves Lafon (W3C), Tony Lee (Vitria Technology Inc.), Michah Lerner (AT&T), Richard Martin (Active Data Exchange), Noah Mendelsohn (Lotus Development), Nilo Mitra (Ericsson Research Canada), Jean-Jacques Moreau (Canon), Masahiko Narita (Fujitsu Software Corporation), Mark Needleman (Data Research Associates), Eric Newcomer (IONA Technologies), Henrik Frystyk Nielsen (Microsoft Corporation), Mark Nottingham (Akamai Technologies), David Orchard (JamCracker), Kevin Perkins (Compaq), Jags Ramnaryan (BEA Systems), Andreas Riegg (Daimler-Chrysler Research and Technology), Herv頒uellan (Canon), Marwan Sabbouh (MITRE Corporation), Shane Sesta (Active Data Exchange), Miroslav Simek (IDOOX s.r.o.), Simeon Simeonov (Allaire), Nick Smilonich (Unisys), Soumitro Tagore (Informix Software), James Tauber (Bowstreet), Lynne Thompson (Unisys), Patrick Thompson (Rogue Wave), Randy Waldrop (WebMethods), Ray Whitmer (Netscape), Volker Wiechers (SAP AG), Stuart Williams (Hewlett-Packard), Amr Yassin (Philips Research) and Dick Brooks (Group 8760).

Previous members were: Eric Fedok (Active Data Exchange) Susan Yee (Active Data Exchange) Alex Milowski (Lexica), Bill Anderson (Xerox), Ed Mooney (Sun Microsystems), Mary Holstege (Calico Commerce), Rekha Nagarajan (Calico Commerce), John Evdemon (XML Solutions), Kevin Mitchell (XML Solutions), Yan Xu (DataChannel) Mike Dierken (DataChannel) Julian Kumar (Epicentric) Miles Chaston (Epicentric) Bjoern Heckel (Epicentric) Dean Moses (Epicentric) Michael Freeman (Engenia Software) Jim Hughes (Fujitsu Software Corporation) Francisco Cubera (IBM), Murray Maloney (Commerce One), Krishna Sankar (Cisco), Steve Hole (MessagingDirect Ltd.) John-Paul Sicotte (MessagingDirect Ltd.) Vilhelm Rosenqvist (NCR) Lew Shannon (NCR) Henry Lowe (OMG) Jim Trezzo (Oracle) Peter Lecuyer (Progress Software) Andrew Eisenberg (Progress Software) David Cleary (Progress Software) George Scott (Tradia Inc.) Erin Hoffman (Tradia Inc.) Conleth O'Connell (Vignette) Waqar Sadiq (Vitria Technology Inc.) Tom Breuel (Xerox) David Webber (XMLGlobal Technologies) Matthew MacKenzie (XMLGlobal Technologies) and Mark Baker (Sun Microsystems).

We also wish to thank all the people who have contributed to discussions on xml-dist-app@w3.org.

D Change Log (Non-Normative)

D.1 SOAP Specification Changes

Date Author Description
20010816 MJH Replaced a mustUnderstand="1" with mustUnderstand="true". Slight rewording in mu description.
20010810 MJH Merged in RPC fault rules text from Jacek. Added new DataEncodingUnknown fault code to SOAP Fault Codes section. Added editorial notes about introduction of new fault code namespace for RPC.
20010809 MJH Merged in "mustHappen" descriptive text from Glen and Noah.
20010809 MJH Fixed language around "default" values of attributes.
20010809 MJH Removed HTTP extension framework, added editorial note to describe why.
20010808 MJH Added Infoset "specified" property text from Chris.
20010808 MJH Removed assumption 4 from version transition appendix.
20010808 MJH Added reference to SOAP 1.1 specification to references section, removed SOAP 1.1 author list from acknowledgments section.
20010807 MJH Converted specification from HTML to XML conforming to W3C XMLSpec DTD. Numerous resulting formatting changes.
20010720 MJG Applied Infoset terminology to sections 1, 2, 3 and 4.
20010629 MJG Amended description of routing and intermediaries in Section 2.1
20010629 JJM Changed "latest version" URI to end with soap12 
20010629 JJM Remove "previous version" URI
20010629 JJM Removed "Editor copy" in <title>
20010629 JJM Removed "Editor copy" in the title.
20010629 JJM Added "Previous version" to either point to SOAP/1.1, or explicitly mention there was no prior draft.
20010629 JJM Pre-filed publication URIs.
20010629 JJM Incorporated David's suggested changes for the examples in section 4.1.1 to 4.4.2
20010629 JJM Fixed some remaining typos.
20010629 MJH Fixed a couple of typos.
20010628 MJG Made various formatting, spelling and grammatical fixes.
20010628 MJG Moved soap:encodingStyle from soap:Envelope to children of soap:Header/soap:Body in examples 1, 2, 47, 48, 49 and 50
20010628 MJG Changed text in Section 2.1 from 'it is both a SOAP sender or a SOAP receiver' to 'it is both a SOAP sender and a SOAP receiver'
20010628 MJG Fixed caption on Example 24
20010628 MJH Fixed a couple of capitalisation errors where the letter A appeared as a capital in the middle of a sentence.
20010628 MJH Updated figure 1, removed ednote to do so.
20010622 HFN Removed the introductory text in terminology section 1.4.3 as it talks about model stuff that is covered in section 2. It was left over from original glossary which also explained the SOAP model.
20010622 HFN Moved the definition of block to encapsulation section in terminology
20010622 HFN Removed introductory section in 1.4.1 as this overlaps with the model description in section 2 and doesn't belong in a terminology section
20010622 HFN Removed reference to "Web Characterization Terminology & Definitions Sheet" in terminology section as this is not an active WD
20010622 HFN Added revised glossary
20010622 HFN Added example 0 to section 1.3 and slightly modified text for example 1 and 2 to make it clear that HTTP is used as a protocol binding
20010622 MJG Added http://example.com/... to list of application/context specific URIs in section 1.2
20010622 MJG Updated examples in section 4.1.1 to be encodingStyle attributes rather than just the values of attributes
20010622 MJG Added table.norm, td.normitem and td.normtext styles to stylesheet. Used said styles for table of fault code values in section 4.4.1
20010622 MJG In Appendix C, changed upgrade element to Upgrade and env to envelope. Made envelope unqualified. Updated schema document to match.
20010622 MJG Moved MisunderstoodHeader from envelope schema into seperate faults schema. Removed entry in envelope schema change table in Appendix D.2 that refered to additon of said element. Modified example in section 4.4.2 to match. Added reference to schema document to section 4.4.2
20010622 MJH Added binding as a component of SOAP in introduction. Fixed a couple of typos and updated a couple of example captions.
20010622 MJG Made BNF in section 6.1.1 into a table.
20010622 MJG Made BNFs in section 5.1 clause 8 into tables. Added associated 'bnf' style for table and td elements to stylesheet
20010622 MJG Amended text regarding namespace prefix mappings in section 1.2
20010622 MJG Added link to schema for the http://www.w3.org/2001/06/soap-upgrade namespace to Appendix C. Updated associated ednote.
20010622 MJG Added reference numbers for XML Schema Recommendation to text prior to schema change tables in Appendix D.2 and linked said numbers to local references in this document
20010622 MJG Reordered entries in schema change classification table in Appendix D.2
20010622 MJG Changed type of mustUnderstand and root attributes to standard boolean and updated schema change tables in Appendix D.2 accordingly
20010622 JJM Manually numbered all the examples (53 in total!)
20010622 JJM Added caption text to all the examples
20010622 JJM Replaced remaining occurrences of SOAP/1.2 with SOAP Version 1.2 (including <title>)
20010621 HFN Added ednote to section 4.2.2 and 4.2.3 that we know they have to be incorporated with section 2
20010621 HFN Added version transition appendix C
20010621 HFN Applied new styles to examples
20010621 HFN Changed term "transport" to "underlying protocol
20010621 HFN Changed example URNs to URLs of the style http://example.org/...
20010621 MJH Updated the Acknowledgements section.
20010621 JJM Added new style sheet definitions (from XML Schema) for examples, and used them for example 1 and 2.
20010621 JJM Incorporated David Fallside's comments on section Status and Intro sections.
20010620 HFN Changed the status section
20010620 HFN Changed title to SOAP Version 1.2 and used that first time in abstract and in body
20010620 HFN Removed question from section 2.4 as this is an issue and is to be listed in the issues list
20010620 HFN Moved change log to appendix
20010615 JJM Renamed default actor to anonymous actor for now (to be consistent)
20010615 JJM Fixed typos in section 2
20010614 JJM Updated section 2 to adopt the terminology used elsewhere in the spec.
20010613 MJH Updated mustUnderstand fault text with additions from Martin Gudgin.
20010613 MJH Added schema changes appendix from Martin Gudgin.
20010613 MJH Added mustUnderstand fault text from Glen Daniels.
20010612 MJH Fixed document <title>.
20010612 MJH Moved terminology subsection from message exchange model section to introduction section.
20010612 MJH Fixed capitalisation errors by replacing "... A SOAP ..." with "... a SOAP ..." where appropriate.
20010612 MJH Removed trailing "/" from encoding namespace URI.
20010612 MJH Fixed links under namespace URIs to point to W3C space instead of schemas.xmlsoap.org.
20010612 MJH Removed some odd additional links with text of "/" pointing to the encoding schema following the text of the encoding namespace URI in several places.
20010611 MJH Incorporated new text for section 2.
20010611 JJM Changed remaining namespaces, in particular next.
20010609 JJM Changed the spec name from XMLP/SOAP to SOAP.
20010609 JJM Changed the version number from 1.1 to 1.2.
20010609 JJM Changed the namespaces from http://schemas.xmlsoap.org/soap/ to http://www.w3.org/2001/06/soap-.
20010609 JJM Replaced the remaining XS and XE prefixes to env and enc, respectively.
20010601 MJH Updated the examples in section 1, 6 and appendix A with text suggested by Martin Gudgin to comply with XML Schema Recommendation.
20010601 JJM Updated the examples in section 4 and 5 with text suggested by Martin Gudgin, to comply with XML Schema Recommendation.
20010531 HFN Removed appendices C and D and added links to live issues list and separate schema files.
20010531 MJH Added this change log and updated schemas in appendix C to comply with XML Schema Recommendation.

D.2 XML Schema Changes

The envelope and encoding schemas have been updated to be compliant with the XML Schema Recomendation[6][7]. The table below shows the categories of change.

Class Meaning
Addition New constructs have been added to the schema
Clarification The meaning of the schema has been changed to more accurately match the specification
Deletion Constructs have been removed from the schema
Name The schema has been changed due to a datatype name change in the XML Schema specification
Namespace A namespace name has been changed
Semantic The meaning of the schema has been changed
Style Style changes have been made to the schema
Syntax The syntax of the schema has been updated due to changes in the XML Schema specification

The table below lists the changes to the envelope schema.

Class Description
Namespace Updated to use the http://www.w3.org/2001/XMLSchema namespace
Namespace Value of targetNamespace attribute changed to http://www.w3.org/2001/06/soap-envelope
Clarification Changed element and attribute wildcards in Envelope complex type to namespace="##other"
Clarification Changed element and attribute wildcards in Header complex type to namespace="##other"
Clarification Added explicit namespace="##any" to element and attribute wildcards in Body complex type
Clarification Added explicit namespace="##any" to element and attribute wildcards in detail complex type
Clarification Added an element wildcard with namespace="##other" to the Fault complex type
Name Changed item type of encodingStyle from uri-reference to anyURI
Name Changed type of actor attribute from uri-reference to anyURI
Name Changed type of faultactor attribute from uri-reference to anyURI
Semantic Added processContents="lax" to all element and attribute wildcards
Semantic Changed type of the mustUnderstand attribute from restriction of boolean that only allowed 0 or 1 as lexical values to the standard boolean in the http://www.w3.org/2001/XMLSchema namespace. The lexical forms 0, 1, false, true are now allowed.
Style Where possible comments have been changed into annotations
Syntax Changed all occurences of maxOccurs="*" to maxOccurs="unbounded"
Syntax Added <xs:sequence> to all complex type definitions derived implicitly from the ur-type
Syntax Added <xs:sequence> to all named model group definitions

The table below lists the changes to the encoding schema.

Class Description
Namespace Updated to use the http://www.w3.org/2001/XMLSchema namespace
Namespace Value of targetNamespace attribute changed to http://www.w3.org/2001/06/soap-encoding
Semantic Changed type of the root attribute from restriction of boolean that only allowed 0 or 1 as lexical values to the standard boolean in the http://www.w3.org/2001/XMLSchema namespace. The lexical forms 0, 1, false, true are now allowed.
Addition Added processContents="lax" to all element and attribute wildcards
Syntax Changed base64 simple type to be a vacuous restriction of the base64Binary type in the http://www.w3.org/2001/XMLSchema namespace
Syntax Updated all complex type definitions with simple base types to new syntax
Syntax Added <xs:sequence> to all complex type definitions derived implicitly from the ur-type
Syntax Added <xs:sequence> to all named model group definitions
Deletion Removed the timeDuration datatype
Addition Added duration datatype derived by extension from the duration datatype in the http://www.w3.org/2001/XMLSchema namespace.
Deletion Removed the timeInstant datatype
Addition Added dateTime datatype derived by extension from the dateTime datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added gYearMonth datatype derived by extension from the gYearMonth datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added gYear datatype derived by extension from the gYear datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added gMonthDay datatype derived by extension from the gMonthDay datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added gDay datatype derived by extension from the gDay datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added gDay datatype derived by extension from the gDay datatype in the http://www.w3.org/2001/XMLSchema namespace.
Deletion Removed the binary datatype
Addition Added hexBinary datatype derived by extension from the hexBinary datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added base64Binary datatype derived by extension from the base64Binary datatype in the http://www.w3.org/2001/XMLSchema namespace.
Deletion Removed the uriReference datatype
Addition Added anyURI datatype derived by extension from the anyURI datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added normalizedString datatype derived by extension from the normalizedString datatype in the http://www.w3.org/2001/XMLSchema namespace.
Addition Added token datatype derived by extension from the token datatype in the http://www.w3.org/2001/XMLSchema namespace.
Clarification Added explicit namespace="##any" to all element and attribute wildcards which did not previously have an explicit namespace attribute
Style Where possible comments have been changed into annotations

In addition several changes occured in the names of datatypes in the XML Schema specification and some datatypes were removed. The following table lists those changes.

Datatype Class Description
timeDuration Renamed New name is duration
timeInstant Renamed New name is dateTime
recurringDuration Removed The recurringDuration datatype no longer exists.
recurringInstant Removed The recurringInstant datatype no longer exists.
binary Removed The binary datatype has been replaced by the hexBinary and base64Binary datatypes.
month Renamed New name is gYearMonth
timePeriod Removed The timePeriod datatype no longer exists
year Renamed New name is gYear
century Removed The century datatype no longer exists
recurringDate Renamed New name is gMonthDay
recurringDay Renamed New name is gDay