The method parameters in the SEI correspond to the wsdl:message
elements and their
wsdl:part
elements. JAX-WS provides annotations that allow you to describe the
wsdl:part
elements that are generated for the method parameters.
The @WebParam
annotation is defined by the javax.jws.WebParam
interface. It is placed on
the parameters of the methods defined in the SEI. The @WebParam
annotation allows you to specify the direction
of the parameter, if the parameter will be placed in the SOAP header, and other properties of the generated wsdl:part
.
Table 1.7 describes the properties of the @WebParam
annotation.
Table 1.7. @WebParam
Properties
Property | Values | Description |
---|---|---|
name | Specifies the name of the parameter as it appears in the generated WSDL document. For RPC bindings, this is the name of the
wsdl:part representing the parameter. For document bindings, this is the local name of the XML element representing the parameter.
Per the JAX-WS specification, the default is arg , where N is replaced
with the zero-based argument index (i.e., arg0, arg1, etc.). | |
targetNamespace | Specifies the namespace for the parameter. It is only used with document bindings where the parameter maps to an XML element. The default is to use the service's namespace. | |
mode |
| Specifies the direction of the parameter. |
header |
| Specifies if the parameter is passed as part of the SOAP header. |
partName | Specifies the value of the name attribute of the wsdl:part element for the parameter. This property
is used for document style SOAP bindings. | |
[a] Any parameter that implements the |
The @WebResult
annotation is defined by the javax.jws.WebResult
interface. It is placed
on the methods defined in the SEI. The @WebResult
annotation allows you to specify the properties of the
wsdl:part
that is generated for the method's return value.
Table 1.8 describes the properties of the @WebResult
annotation.
Table 1.8. @WebResult
Properties
Example 1.7 shows an SEI that is fully annotated.
Example 1.7. Fully Annotated SEI
package com.fusesource.demo; import javax.jws.*; import javax.xml.ws.*; import javax.jws.soap.*; import javax.jws.soap.SOAPBinding.*; import javax.jws.WebParam.*; @WebService(targetNamespace="http://demo.fusesource.com", name="quoteReporter") @SOAPBinding(style=Style.RPC, use=Use.LITERAL) public interface quoteReporter { @WebMethod(operationName="getStockQuote") @RequestWrapper(targetNamespace="http://demo.fusesource.com/types", className="java.lang.String") @ResponseWrapper(targetNamespace="http://demo.fusesource.com/types", className="org.eric.demo.Quote") @WebResult(targetNamespace="http://demo.fusesource.com/types", name="updatedQuote") public Quote getQuote( @WebParam(targetNamespace="http://demo.fusesource.com/types", name="stockTicker", mode=Mode.IN) String ticker ); }