The optional soap fault element is used to retain the error and status information of the SOAP message.
SOAP Fault Element
Error messages from SOAP messages are carried inside the Fault element.
If a Fault element is provided, it must be a child element of the Body element. In a SOAP message, the Fault element can only appear once.
The Fault Element of SOAP is used for the sub-elements of the following columns:
Child Element |
Description |
<Faultcode> |
Code for Fault Identification |
<Faultstring> |
Fault description for users |
<Faultactor> |
Information about who caused the fault |
<Detail> |
Persists application-specific error messages involving the body Element |
SOAP Fault Codes
The faultcode value defined below must be used in the faultcode element for fault description:
Error |
Description |
Versionmismatch |
Invalid namespace of the soap envelope element is found |
Mustunderstand |
A direct sub-element of the Header element (with the mustunderstand attribute set to "1") cannot be understood. |
Client |
Messages are incorrectly formed or contain incorrect information. |
Server |
The server is faulty, so it cannot be processed. |
HTTP protocol
HTTP communicates over TCP/IP. The HTTP client uses TCP to connect to the HTTP server. After a connection is established, the client can send an HTTP request message to the server:
POST /item HTTP/1.1Host: 189.123.345.239Content-Type: text/plainContent-Length: 200
The server then processes the request and sends an HTTP Response to the client. This response contains the status code indicating the Request status:
200 OKContent-Type: text/plainContent-Length: 200
In the preceding example, the server returns a 200 status code. This is the standard success code of HTTP.
If the server cannot decode the request, it may return such information:
400 Bad RequestContent-Length: 0
Soap http Binding
A soap method is an HTTP request/response that complies with the SOAP encoding rules.
HTTP + xml = soap
The SOAP request may be an http post or http get request.
The http post request requires at least two HTTP headers: Content-Type and Content-Length.
Content-Type
The Content-Type header of the SOAP request and response defines the MIME type of the message and the character encoding of the XML Entity used for the request or response (optional ).
Syntax
Content-Type: MIMEType; charset=character-encoding
Example
POST /item HTTP/1.1Content-Type: application/soap+xml; charset=utf-8
Content-Length
The Content-Length header of the SOAP request and response specifies the number of bytes of the request or response body.
Syntax
Content-Length: bytes
Example
POST /item HTTP/1.1Content-Type: application/soap+xml; charset=utf-8Content-Length: 250
A soap instanceIn the following example, A getstockprice request is sent to the server. This request has a stockname parameter, and a price parameter is returned in the response. The namespace for this feature is defined in this address: "http://www.example.org/stock"
SOAP request:POST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>
Soap response:HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>
Soap OverviewThis tutorial describes how to use soap to exchange information between applications over HTTP.
You have learned about different elements and attributes in a SOAP message.
You also learned how to use soap as a protocol to access web services.