The Web Service implementation class is a session bean 3.0, annotated with the @WebService tag. Concretely, this EJB 3.0 will access the existing Session Bean of the TroubleTicket application and invoke corresponding methods.
The needed annotations are :
- @Stateless: to specify this class is a Stateless Session Bean;
- @WebService: to indicate JAX-WS this file is a web service, so that artifacts will be created;
- @WebMethod: for JAX-WS too, indicating that this method is exposed. This annotation is optional: in fact, every method of the endpoint will be exposed.
Note an important modification relativ to the EJB access : when accessing an EJB 2.1 or previous version from an EJB 3.0, the object returned by the lookup function can not be casted. The use of an intermediary method, javax.rmi.PortableRemoteObject.narrow method is mandatory, as specified by the EJB 3.0 specification.
Netbeans handles automatically the @WebService annotation by creating the ant target 'wsgen-generate' for producing the endpoint of this web service. As this point wsgen execution should be possible. But JAX-B -a sub-tool of JAX-WS, in charge of the binding between XML and Java types- will encounter obstacle to compute interfaces definitions: error message like "JAX'B can't handle with interfaces..." will be generated. Next post explains how to handle the generation from interfaces definitions.