Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

10.5 Introduction to the SOAP HTTP binding

SOAP defines a binding to the HTTP protocol. This binding describes the relationship between parts of the SOAP request message and various HTTP headers. All SOAP requests use the HTTP POST method and specify at least three HTTP headers: Content-Type, Content-Length, and a custom header SOAPAction. The actual SOAP message is passed as the body of the request or response.



10.5.1 Content-Type



Content-Type: text/xml; charset=character encoding

The Content-Type header for SOAP requests and responses specifies the MIME type for the message and is always text/xml. It may also specify the character encoding used for the XML body of the HTTP request or response. This follows the text/xml part of the header values.

Example Use of Content-Type

POST /endpoint.pl HTTP/1.1
Content-Type: text/xml

An example Content-Type header in an HTTP request

10.5.2 Content-Length

The Content-Length header for SOAP requests and responses is set to the number of bytes in the body of the request or response.

Examples Use of Content-Length

POST /endpoint.pl HTTP/1.1
Content-Type: text/xml
Content-Length: 167
SOAPAction: urn:example-org:demos#Method

<s:Envelope 
  xmlns:s='http://schemas.xmlsoap.org/soap/envelope/' >
 <s:Body>
  <m:Method xmlns:m='urn:example-org:demos' />
 </s:Body>
</s:Envelope>

An example Content-Length header in an HTTP request. The request is encoding using an 8-bit encoding format.

Use of Content-Length with charset

POST /endpoint.pl HTTP/1.1
Content-Type: text/xml; charset=UTF-16
Content-Length: 167
SOAPAction: urn:example-org:demos#Method

<s:Envelope 
  xmlns:s='http://schemas.xmlsoap.org/soap/envelope/' >
 <s:Body>
  <m:Method xmlns:m='urn:example-org:demos' />
 </s:Body>
</s:Envelope>

An example Content-Length header in an HTTP request. The request is encoding using a 16-bit encoding format.

10.5.3 SOAPAction

The SOAPAction header indicates to the HTTP server that the request is a SOAP request. The value of the header is a URI. Beyond that, its value is undefined.

Example Use of SOAPAction

POST /endpoint.pl HTTP/1.1
Content-Type: text/xml; charset=UTF-16
Content-Length: 167
SOAPAction: urn:example-org:demos#Method

<s:Envelope 
  xmlns:s='http://schemas.xmlsoap.org/soap/envelope/' >
 <s:Body>
  <m:Method xmlns:m='urn:example-org:demos' />
 </s:Body>
</s:Envelope>

An example SOAPAction header in an HTTP request. The string preceding the # is the namespace name of the first child of the Body element whereas the string following the # is the local name of that element.

  • + Share This
  • 🔖 Save To Your Account