Adding Web service annotation tags

Annotation-based programming tags are used within your EJB Projects or Web projects as providers of metadata that is then used to generate other application artifacts as required. Annotation tags are added to the comments section at the top of a Java™ file.

Adding annotation tags to a Java bean

  1. You can automatically generate an annotated bean class using the Create an Enterprise Bean page. Select Generate an annotated bean class, and it creates a default annotated bean class for you.
  2. Create or import a Java package and its required classes into the project.
  3. Add any required annotation tags to the comment section at the top of the Java file. When creating a Web service from a Java bean, the only required annotation tag is @WebSphere.WebService.

Example: The following Java code creates a Web service that uses document literal encoding and style, and contains an operation called "Bye."

Annotated class code

Adding annotation tags to an EJB bean

  1. Adding annotation tag support can be done using the New EJB Project wizard. On the New EJB Project page, click Show Advanced. Select the Add support for annotated Java classes check box.
    Add support for annotated Java classes
  2. Create or import a Java package and its required classes into the project.
  3. Add any required annotation tags to the comment section at the top of the Java file. When creating an EJBWeb service from a Java bean, the required annotation tags are @WebSphere.WebService and @ejb.session.

Example: The following Java code creates a stateless session EJB Web service that uses document literal encoding and style, and contains an operation called "sayhello."

Annotated class code


Feedback