Webmethod and Webparam

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

javax.jws.

WebMethod

Annotation :
The @WebMethod annotation denotes a method that is a Web service operation. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint. Important : The @WebMethod annotation is only supported on classes that are annotated with the @WebService annotation.

Properties :

Annotation target: Method Properties: - operationName Specifies the name of the wsdl:operation matching this method. The default value is the name of Java method. (String) - action Defines the action for this operation. For SOAP bindings, this value determines the value of the SOAPAction header. The default value is the name of Java method. (String) - exclude Specifies whether to exclude a method from the Web service. The default value is false. (Boolean)

Annotation Type Definition


@Retention(value=RetentionPolicy.RUNTIME) @Target({METHOD}) public @interface WebMethod { String operationName() default ""; String action() default ""; boolean exclude() default false; }

Example
@WebService(targetNamespace = "http://duke.org", name="AddNumbers") public interface AddNumbersIF extends Remote { @WebMethod(operationName="add", action="urn:addNumbers") public int addNumbers(int number1, int number2) throws RemoteException, AddNumbersException; }

javax.jws.WebParam

Annotation :

The @WebParam annotation customizes the mapping of an individual parameter to a Web service message part and XML element. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class for a JavaBeans endpoint.

Properties :

Annotation target: Parameter Properties: - name The name of the parameter. If the operation is remote procedure call (RPC) style and the partName attribute is not specified, then this is the name of the wsdl:part attribute representing the parameter. If the operation is document style or the parameter maps to a header, then -name is the local name of the XML element representing the parameter. This attribute is required if the operation is document style, the parameter style is BARE, and the mode is OUT or INOUT. (String) - partName Defines the name of wsdl:part attribute representing this parameter. This is only used if the operation is RPC style, or the operation is document style and the parameter style is BARE. (String) - targetNamespace Specifies the XML namespace of the XML element for the parameter. Applies only for document bindings when the attribute maps to an XML element. The default value is the targetNamespace for the Web service. (String) - mode The value represents the direction the parameter flows for this method. Valid values are IN, INOUT, and OUT. (String) - header Specifies whether the parameter is in a message header rather than a message body. The default value is false. (Boolean)
@Retention(value=RetentionPolicy.RUNTIME) @Target({PARAMETER}) public @interface WebParam { public enum Mode { IN, OUT, INOUT }; String name() default ""; String targetNamespace() default ""; Mode mode() default Mode.IN; boolean header() default false; String partName() default ""; }

You might also like