In the HelloWorldEJB project, you create a session Enterprise Java Bean which provides the business logic of the Web service.
In the ProjectExplorer , choose the HelloWorldEJB project, and then choose .
In the list of wizards, choose Next .
, and then chooseIn the EJB ClassName field, enter HelloBean .
Make sure that the EJBProject field contains the HelloWorldEJB project.
In the DefaultEJBPackage field, enter com.sap.tutorial.helloworld .
In the Create BusinessInterface area, select Remote and Local , and then choose Finish .
The system opens the created EJB session bean for editing.
Update the source code as shown in the sample below.
The code sample below shows the implementation of a Java class which returns the following string: Hello, <name> . The value of the variable <name> is provided by user input.
package com.sap.tutorial.helloworld; import javax.ejb.Stateless; @Stateless(name="HelloBean") public class HelloBean implements HelloRemote, HelloLocal { private String message = "Hello, "; public String sayHello(String name) { return message + name + "."; } }
In the ProjectExplorer , expand the HelloWorldEJB project, and then choose .
Right-click sayHello(String) , and then choose EJB .
Save your changes.
The HelloBean appears in the HelloWorldEJB project. The sayHello method is added to the local and remote Java interfaces. At this point, the implementation session bean is ready to be exposed as a Web service.