Skip to main content

Body

Required

SOAP 1.1: Required. One child element = operation name

SOAP 1.2: Required. Same structure.

The Body is the mandatory element containing the actual SOAP message payload – the operation and parameters (request) or the return value (response). On error, the Body contains a Fault element. The Body always has exactly one direct child element: the operation wrapper.

Details

The Body is the primary payload of the SOAP message. It MUST be present in every SOAP message and MUST be the last child of the Envelope (or the only child if no Header is present).

Request body: The direct child of Body is an element named after the operation, containing the operation's parameters as child elements.

Response body: The response body's direct child is typically the operation name with 'Response' appended (e.g., GetCustomerResponse), wrapping the return values.

Document vs RPC style: RPC style: Body contains an element named after the operation with parameters as children. The operation name is critical for dispatch. Document style: Body contains arbitrary XML documents. The operation is identified by WS-Addressing Action header or SOAPAction. More flexible, preferred for complex payloads.

XML Schema types: Body parameters are typed by XML Schema definitions in the WSDL. This enables strict validation and code generation.

Empty Body: A Body element with no children is valid for certain notification-style messages (fire-and-forget). In practice, most SOAP services require a response.

Attributes

AttributeDescription
soap:encodingStyleSOAP 1.1: encoding style URI for typed values. Deprecated in SOAP 1.2.

Examples

RPC-style request body
<soap:Body>
  <ex:GetCustomerRequest xmlns:ex="http://example.com/customer">
    <ex:CustomerId>cust-123</ex:CustomerId>
    <ex:IncludeOrders>true</ex:IncludeOrders>
  </ex:GetCustomerRequest>
</soap:Body>
Document-style response body
<soap:Body>
  <ex:GetCustomerResponse xmlns:ex="http://example.com/customer">
    <ex:Customer>
      <ex:Id>cust-123</ex:Id>
      <ex:Name>Alice</ex:Name>
      <ex:Orders>
        <ex:Order><ex:Id>ord-1</ex:Id></ex:Order>
      </ex:Orders>
    </ex:Customer>
  </ex:GetCustomerResponse>
</soap:Body>

See Also