Java Reference
In-Depth Information
The
operationName
and
action
properties on the
@WebMethod
annotation specify
the operation and SOAP action, respectively. The following example shows their use:
@WebMethod(operationName = "addNewBid",
action = http://actionbazaar.com/NewBid)
public Long addBid(...) {
...
}
The
operationName
will result in the following WSDL being generated:
<portType name="PlaceBidBean">
<operation name = "addNewBid">
...
</operation>
</portType>
Notice how the actual method name is
addBid
but the method name exposed in the web
service is
addNewBid
. You can use this to help map the service contract to the actual im-
plementation. Even if the implementation changes over time, the contract remains intact.
If the
operationName
isn't specified, it'll default to the implementation name of the
method. This can also be used in situations where the WSDL file is created separately and
for some reason the method name shouldn't be exposed.
Similarly, the action element you defined earlier will be used for generating the
SOAPAc-
tion
in the WSDL as follows:
<operation name ="addNewBid">
<soap:operation soapAction = "http://actionbazaar.com/NewBid"/>
</operation>
The
SOAPAction
element determines the
header
element in the HTTP request mes-
sage. The web service client uses it when communicating with the web service using SOAP
over HTTP. The content of the
SOAPAction
header field is used by the endpoint to de-
termine the true intended destination rather than having to parse the SOAP message body
to find the information. Now that you have a firm grasp of the
@WebMethod
annotation,
let's dig into the
@WebParam
, which is naturally related.