SOAP - SOAPAction
What is SOAPAction?
-
SOAPAction is an HTTP header used in SOAP 1.1 requests.
-
It tells the server which operation (method) you want to call inside the web service.
-
Without it, the server might not know which method to execute, especially if multiple operations exist in the same service.
Format
SOAPAction: "namespace/MethodName"
-
It usually matches the operation’s namespace and name defined in the WSDL.
-
Example:
"http://example.com/hello/SayHello"
Example Request with SOAPAction
HTTP Headers
POST /hello.asmx HTTP/1.1
Host: example.com
Content-Type: text/xml; charset=utf-8
Content-Length: 300
SOAPAction: "http://example.com/hello/SayHello"
SOAP Body
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://example.com/hello">
<soap:Body>
<tns:SayHello>
<tns:name>John</tns:name>
</tns:SayHello>
</soap:Body>
</soap:Envelope>
SOAPAction in SOAP Versions
-
SOAP 1.1 → Requires the
SOAPAction
HTTP header. -
SOAP 1.2 → Uses a different header (
Content-Type
withaction
parameter). Example:Content-Type: application/soap+xml; charset=utf-8; action="http://example.com/hello/SayHello"
In C# / .NET
-
If you generate a client proxy (via Add Service Reference), .NET automatically includes the correct SOAPAction in the HTTP headers.
-
If you make manual calls (using
HttpClient
), you must set the header yourself:
content.Headers.Add("SOAPAction", "http://example.com/hello/SayHello");
In short:
SOAPAction is like a “method selector” — it tells the server exactly which operation you want to invoke in a SOAP service.