In this section, you will insert a method in the web service to call a method on the custom control.
In the Select Control dialog, note that you can choose from various existing controls, including MailingListControl, the one you created earlier in the controls package.
In Design View, the web service should look like this:
The web service code in Source View should be as follows:
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. 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.
You will now add a method to the service that will call a method on mailingListControl, the instance of MailingListControl you just created.
A corresponding method is added to the web service client interface.
The source code for the web service class should now be as follows:
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"; } @WebMethod public model.Customer[] getLocalCustomers() { return mailingListControl.getLocalCustomers(); } }
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: