Java Reference
In-Depth Information
Creating a Web Service Operation
Problem
You want to define an operation on a web service.
Solution
Simply add a public method to the service implementation class that defines the @WebService ,
and it will automatically be added to the generated WSDL.
Any public methods you add to an annotated service class will automatically be added to the
WSDL operations; if you want to accept the default mappings, you don't need to do anything
else.
Discussion
You can explicitly specify a Java method as a service operation by annotating it with the @We-
bMethod annotation. But the annotation also allows you to specify certain properties of how
the operation will be represented in the WSDL and how it will behave. These properties are
listed in Table 7-2 .
Table7-2.@WebMethod properties
Property
Purpose
operationName Customizes the value of the wsdl:operation if starting from Java, or mapping to an exist-
ing WSDL.
action
In SOAP, sets the value of the action.
exclude
Indicates that you explicitly do not want this method exposed as an operation in the WSDL.
It is illegal to specify this on endpoint interfaces. It is illegal to specify any other properties
of @WebMethod if you specify this one.
NOTE
If you use the @WebMethod annotation on a single method in your Java class, you must explicitly set
it on all remaining methods you want to be included in the service definition. Otherwise, JAX-WS
will think you intend to exclude them, and they won't be added to the WSDL.
Search WWH ::




Custom Search