Previous Next vertical dots separating previous/next from contents/index/pdf

Step 7: Use the Control from the Web Service

In this section, you will insert a method in the web service to call a method on the custom control.

Insert a Control

  1. In the Package Explorer, double-click the web service file MailingListService.java.
  2. Right-click in the Design View editor and select New Control Reference.
  3. The Select Control dialog box appears.

    Note that this dialog lets you choose from various existing controls, including MailingListControl, the one you created earlier in the controls package.

    Select MailingListControl - controls, and click OK.

  4. Press Ctrl+Shift+S to save your work.

In Design View, the web service should look like this:

In Source View, the web service should now look like this:

package services;


import javax.jws.*;
import org.apache.beehive.controls.api.bean.Control;
import controls.MailingListControl;

@WebService public class MailingListService { @Control private MailingListControl mailingListControl; @WebMethod
public String getCustomers() {
return "John Smith";
} }

Note that Workshop for WebLogic added the required imports for MailingListControl, the control you told it to insert. It also added a variable declaration for a control of type MailingListControl named mailingListControl. Workshop for Weblogic declared mailingListControl to be a control by adding the @Control annotation.

Call a Method on the Control

You will now add a method to the service that will call a method on mailingListControl, the instance of MailingListControl you just created.

  1. In Design View, right-click the control method getLocalList and select Generate Delegate Method.

    A corresponding method is added to the web service client interface.

The web service class should now look like this:

package services;
import javax.jws.*;
import org.apache.beehive.controls.api.bean.Control;
import controls.MailingListControl;

import model.Customer;


@WebService
public class MailingListService {
   @Control
   private MailingListControl mailingListControl;


   @WebMethod()
   public String getCustomers() {
return "John Smith"; } @WebMethod() public Customer[] getLocalList() {
return mailingListControl.getLocalCustomers(); } }

 

In Design View the web service looks like this:

The new method calls the control method getLocalCustomers, which will return an array of Customer objects for all customers in California in the sample database.

In the next step, we will test the new method.

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

 

Skip navigation bar   Back to Top