O'Reilly logo

Java SOA Cookbook by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 soapAction 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 approach has disadvantages. For the more academically inclined, relying on the transport ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required