4-6 Getting Started With JAX-WS Web Services for Oracle WebLogic Server
You can also use the action attribute to specify the action of the operation. When using SOAP as a binding, the value of the action attribute determines the value of
the SOAPAction header in the SOAP messages.
To exclude a method as a Web service operation, specify WebMethodexclude=true.
You can specify that an operation not return a value to the calling application by using the standard Oneway annotation, as shown in the following example:
public class OneWayImpl { WebMethod
Oneway public void ping {
System.out.printlnping operation; }
...
If you specify that an operation is one-way, the implementing method is required to return void, cannot use a Holder class as a parameter, and cannot throw any checked
exceptions.
None of the attributes of the WebMethod annotation is required. See the Web Services Metadata for the Java Platform JSR 181 at
http:www.jcp.orgenjsrdetail?id=181 for the default values of each
attribute, as well as additional information about the WebMethod and Oneway annotations.
4.3.5 Customizing the Mapping Between Operation Parameters and WSDL Elements WebParam Annotation
Use the standard WebParam annotation to customize the mapping between operation input parameters of the Web service and elements of the generated WSDL
file, as well as specify the behavior of the parameter, as shown in the following code excerpt:
public class SimpleImpl { WebMethod
WebResultname=IntegerOutput, targetNamespace=http:example.orgdocLiteralBare
public int echoInt WebParamname=IntegerInput,
targetNamespace=http:example.orgdocLiteralBare
int input {
System.out.printlnechoInt + input + to you too; return input;
} ...
In the example, the name of the parameter of the echoInt operation in the generated WSDL is IntegerInput; if the WebParam annotation were not present in the JWS
file, the name of the parameter in the generated WSDL file would be the same as the
Note: For JAX-WS, the service endpoint interface SEI defines the
public methods. If no SEI exists, then all public methods are exposed as Web service operations, unless they are tagged explicitly with
WebMethodexclude=true.
Programming the JWS File 4-7
name of the methods parameter: input. The targetNamespace attribute specifies that the XML namespace for the parameter is
http:example.orgdocLiteralBare ; this attribute is relevant only when
using document-style SOAP bindings where the parameter maps to an XML element. You can also specify the following additional attributes of the WebParam annotation:
■
mode —The direction in which the parameter is flowing WebParam.Mode.IN,
WebParam.Mode.OUT , or WebParam.Mode.INOUT. OUT and INOUT modes
are only supported for RPC-style operations or for parameters that map to headers.
■
header —Boolean attribute that, when set to true, specifies that the value of the
parameter should be retrieved from the SOAP header, rather than the default body.
None of the attributes of the WebParam annotation is required. See the Web Services Metadata for the Java Platform JSR 181 at
http:www.jcp.orgenjsrdetail?id=181 for the default value of each
attribute.
4.3.6 Customizing the Mapping Between the Operation Return Value and a WSDL Element WebResult Annotation
Use the standard WebResult annotation to customize the mapping between the Web service operation return value and the corresponding element of the generated WSDL
file, as shown in the following code excerpt:
public class Simple { WebMethod
WebResultname=IntegerOutput, targetNamespace=http:example.orgdocLiteralBare
public int echoInt WebParamname=IntegerInput,
targetNamespace=http:example.orgdocLiteralBare int input
{ System.out.printlnechoInt + input + to you too;
return input; }
...
In the example, the name of the return value of the echoInt operation in the generated WSDL is IntegerOutput; if the WebResult annotation were not present
in the JWS file, the name of the return value in the generated WSDL file would be the hard-coded name return. The targetNamespace attribute specifies that the XML
namespace for the return value is http:example.orgdocLiteralBare; this attribute is relevant only when using document-style SOAP bindings where the return
value maps to an XML element.
None of the attributes of the WebResult annotation is required. See the Web Services Metadata for the Java Platform JSR 181 at
http:www.jcp.orgenjsrdetail?id=181 for the default value of each
attribute.
4.3.7 Specifying the Binding to Use for an Endpoint BindingType Annotation