Java Reference
In-Depth Information
good deal of sense. In fact, that's some of the basis for the justification for creating the WS-
Addressing specification. WS-Addressing still provides routing information in a manner sim-
ilar to
SOAPAction
, but it does so in structured SOAP headers, not HTTP headers.
The Basic Profile (the specification from the Web Services Interoperability consortium that
provides guidelines for ensuring that web services are interoperable across multiple platforms)
requires that
SOAPAction
be present and its value must be a quoted string. But the string can
be empty. Java implementations, including the SAAJ and JAX-WS reference implementa-
tions, will automatically add
SOAPAction
as a header, and give it a value of “” (empty string).
This complies with the Basic Profile and doesn't break encapsulation.
Another thing to consider is that the WSDL 1.2 and 2.0 specifications make
soapAction
op-
tional, so they may be deprecated before too long in favor of elements provided by the WS-
Addressing specification.
Some web services, particularly those implemented in .NET, require you to specify a real
value for a
SOAPAction
header. In Java, this will be created, but its value will be an empty
string.
The
SOAPAction
will typically look something like this:
POST /stockquote.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.webserviceX.NET/GetQuote"
If you don't specify it, the service will complain. Adding a
SOAPAction
is turned off by de-
fault on both the
Dispatch
and
Call
objects that are used to send messages. In order to use
services that require a
SOAPAction
, you have to do two things: enable the message to provide
a value for
SOAPAction
and then provide the value.
Because you have to enable it this way,
SOAPAction
is notjust another MIME header like
any other you might want to add. So let's look at a web service from the good folks at
ht-
tp://webservicesx.net
,
which has been around for a few years.