Java Reference
In-Depth Information
Specifying SOAPAction
Problem
You need to specify the
SOAPAction
MIME header to invoke a web service that requires one.
Solution
You need to enable the ability to send a
SOAPAction
on your
Dispatch
or
Call
object. Then
set its value to the URI that is required by the service, as specified by the operation's
soapAc-
tion
attribute.
Discussion
SOAPAction
is an HTTP header that is specified on SOAP requests. It was originally used to
provide routing information in headers. Because headers don't require inspecting the SOAP
payload, they are quick to access, and were found to improve performance. Firewalls, filters,
or routing agents can simply check the value of
SOAPAction
to determine the endpoint and
operation the message is destined for.
The decision whether to employ
SOAPAction
is left to the implementer of the web service. If
you choose to, it is specified on the concrete aspect of the WSDL in the SOAP binding:
<wsdl:operation name="GetQuote">
<soap:operation style="document"
soapAction="http://www.webserviceX.NET/GetQuote" />
...
In a SOAP request, the
SOAPAction
value must be a string, in quotes, that matches the value
specified by the
soapAction
attribute in the WSDL. The following HTTP header would need
to be set to match the
soapAction
specified in the WSDL just shown:
SOAPAction: "http://www.webserviceX.NET/GetQuote"
While performance can certainly still be an issue with SOAP-based web services, this ap-
proach has disadvantages. For the more academically inclined, relying on the transport pro-
tocol (HTTP) to include SOAP-specific information is problematic. While taking advantage
of headers for certain incidental data or metadata may be acceptable, allowing the internal de-
tails of the contained message to ooze out into the transport layer is not encapsulated. It's like
passing a JPanel into a DAO. It is suggested that rather than specifying routing information
externally, it should be located instead in the SOAP message itself. This argument makes a