You can use the @WebService and @WebMethod annotations on a service endpoint implementation to specify Java™ methods that you want to expose as Java API for XML-Based Web Services (JAX-WS) Web services.
JAX-WS technology enables the implementation of Web services based on both the standard service endpoint interface and a Provider interface. When developing a JAX-WS Web service starting from existing Java classes, known as the bottom-up approach, you must annotate the class with either the @WebService or @WebServiceProvider annotation to initially define the class as a Web service.
Using the Provider interface is the dynamic approach to defining your JAX-WS services. To use the Provider interface, your class must implement the javax.xml.ws.Provider interface, and contain the @WebServiceProvider annotation. The Provider interface has one method, the invoke method, which uses generics in the Java programming language to control both the input and output types when working with various messages or message payloads.
In contrast, this topic describes how you can use Java annotations to describe your Web services using the service endpoint interface (SEI) approach.
To initially define a Web service, annotate the Java class with the @WebService annotation. However, you can also selectively annotate the individual methods with @WebMethod annotation to control how these methods are exposed as Web services operations.
Using a combination of @WebService and @WebMethod annotations, you can easily describe your Web service because you control which methods are exposed.
Because of ambiguities across multiple Web services specifications regarding how methods are exposed as operations, use the following guidelines to help ensure consistent behavior regardless of the JAX-WS implementation that you use.
To define a class as an SEI-based Web Service, you must add the @WebService annotation to the implementation class. Providing a reference to an explicit SEI (interface) or a reference to an existing WSDL file in your service endpoint implementation class helps to remove possible ambiguities when exposing methods.
You have used the @WebMethod annotation to specify which methods to expose as Web services operations.
If you have upgraded your application server environment to include Sun or HP JDK 1.6 and you are experiencing problems, review the following troubleshooting information.
javax.xml.ws.WebServiceException: The Endpoint validation failed to validate due to the following errors: :: Invalid Endpoint Interface :: :: The number of operations in the WSDL portType does not match the number of methods in the SEI or Web service implementation class. wsdl operations = [...] dispatch operations = [....]
To correct this problem, you must regenerate client artifacts to match the WSDL file.
The endpoint reference (EPR) for the Operation not found is http://localhost:9086/example/BeanImpl2Service and the WSA Action = <WSA_action_from_server>. If this EPR was previously reachable, contact the server administrator.
Develop Java artifacts for JAX-WS applications from JavaBeans™.
In this information ...Related tasks
Related reference
| IBM Redbooks, demos, education, and more(Index) |