Customizing the Mapping Between Operation Parameters and WSDL Elements WebParam Annotation

Programming the JWS File 4-7

4.3.6 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 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. The OUT and INOUT modes may be specified only for parameter types that conform to the JAX-RPC definition of Holder types. 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.7 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, 4-8 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server 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.4 Accessing Run-Time Information About a Web Service