1. What is SOAP Encoding?
http://schemas.xmlsoap.org/soap/encoding/
-
It tells the sender and receiver how to serialize (encode) or deserialize (decode) data like integers, strings, arrays, objects, etc., into XML format.
2. Why is SOAP Encoding Needed?
3. SOAP Encoding Styles
There are two common encoding styles:
-
Literal Encoding (document/literal)
-
SOAP Encoding (RPC/encoded)
4. Example: SOAP Encoding in Use
Suppose we want to send an array of integers [10, 20, 30].
SOAP Request with Encoding
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<ns1:getNumbers xmlns:ns1="http://example.com/">
<numbers soapenc:arrayType="xsd:int[3]"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<number>10</number>
<number>20</number>
<number>30</number>
</numbers>
</ns1:getNumbers>
</soap:Body>
</soap:Envelope>
Explanation:
-
soap:encodingStyle → specifies encoding rules being used.
-
xsd:int → defines the data type (integer).
-
soapenc:arrayType="xsd:int[3]" → tells the receiver it’s an array of 3 integers.
5. Key Points about SOAP Encoding
-
SOAP encoding defines serialization rules for data types in XML.
-
Declared using the attribute:
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
-
Handles simple types (int, string, boolean) and complex types (arrays, objects).
-
Literal encoding is more widely used today (especially with WSDL + Document/Literal style).
-
RPC/encoded style is now less common, but still important to understand for legacy systems.