Java Reference
In-Depth Information
Providing
a
Value
for
SOAP
Action
or
WS-Addressing Action
Problem
You want to specify a value for the soapAction in your WSDL. Or, you want to specify an
action value if you're using WS-Addressing.
Solution
Use the @WebMethod annotation, and specify a value for the action attribute.
Discussion
There is an HTTP header called SOAPAction that accompanies SOAP requests. The value of
this header is dictated by the soapAction attribute value on the soap:operation . Its value
must be a URI that indicates the intended processing resource for the operation. In compliance
with the Basic Profile 1.1, the JAX-WS runtime will specify a set of empty double quotes ( "" )
as the value of the soap:operation element's soapAction attribute if not present.
The following code shows an example of indicating the value for SOAPAction in a Java ser-
vice endpoint implementation:
@WebMethod(operationName="greet",
action="http://soacookbook.com/Hello/sayHello")
public String greet(
@WebParam(name="name") String name) {
return "Hi " + name;
}
By including this attribute in the annotation of your service operation, you'll get two things.
The first is a value in the generated WSDL for the soapAction attribute on the operation, as
shown here:
<operation name="greet">
<soap:operation soapAction="http://soacookbook.com/Hello/sayHello"/>
You will also get an HTTP header accompanying every request you make with this operation
that contains the specified value.
Search WWH ::




Custom Search