# Step 9: Build and Run a Web Service Application

Throughout this tutorial you have used predefined web applications to test the EJBs you develop. However, as you go about developing your own EJBs, you might not be interested in building a page flow in parallel to run and test your EJBs. WebLogic Workshop offers the test web service as a quick alternative to test your beans. In this step you will build your own test web service for the Band bean. This requires generating an EJB control for the EJB, and generating a test web service for the EJB control

The tasks in this step are:

- To Create a Web Service Project
- To Create the EJB Control
- To Generate the Test Web Service
- To Run the Test Web Service

To Create the Web Service Project

1. In the Application tab, right-click the EJBProjectTutorial folder and select New-->Project.
2. In the New Project dialog, in the upper left-hand pane, select Web Services.
   In the upper right-hand pane, select Web Service Project.
   In the Project Name field, enter TestWSProject.
3. Click Create.

To Create the EJB Control

1. Right-click TestWSProject and select New-->Folder. The Create New Folder dialog appears.
2. Enter EJBControls. Click OK.
3. Right-click EJBControls and select New-->Java Control. The New Java Control dialog appears.
4. Select EJB Control. In the File name field, enter BandEJBControl. Click Next.
5. Click Browse application EJBs and select BandEJB (local jndi). Click Select.
6. Click Create.

To Generate the Test Web Service

- In the Application tab, right-click BandEJBControl.jcx and select Generate Test JWS File (Conversational).

To Run the Test Web Service

1. In the Application tab, double-click the BandEJBControlTest.jws web service to open it in Design View.
2. Click the Start button.
   Workshop launches the Workshop Test Browser.
3. In Test View, you can test the EJB using either the Test Form or Test XML tab. Click the Test XML tab to have access to all methods.
4. Click startTestDrive to begin testing. This starts the web service's conversation.
5. After Test View refreshes, click the Continue this conversation link for access to test forms and buttons through which you can test each of your control's methods.
6. You can now test the methods. After each test, click Continue this conversation to test another method.

   For instance, locate the findByName method, supply the name of a band you entered earlier in the tutorial as an argument (for instance, <arg0>Art Ensemble of Chicago</arg0>), and click the findByName button. The test web service returns the reference to the entity bean, as seen in the Returned from findByName section, and stores this reference as part of the conversation state. In other words, you can now use another method to test this bean. For instance, click Continue this conversation, locate the getName method, and click the corresponding getName button. The name of the entity bean, which you located with findByName, is returned, as showing in the Returned from getName section.

   Note. For some methods, such as findByName in the example, you will notice that a value is returned correctly, although an XMLEncodingException error is thrown in the service response. These types of errors result from the return type not being Serializable, which is a prerequisite for a proper XML response. However, these errors do not affect the operations of the EJB or your ability to use the test web service to test the EJB.

7. When you are finished testing, click finishTestDrive to finish testing.
8. Return to WebLogic Workshop and press the Stop button to close the Test Browser.

When you make changes to the Band bean during testing, you will need to rebuild the bean and, if you added/removed methods or changed method signatures, regenerate the test JWS. However, in those cases it is not necessary to recreate the EJB control.

Related Topics

How Do I: Test an Enterprise JavaBean?

Building Web Services

Click one of the following arrows to navigate through the tutorial: