![]() |
![]() |
![]() |
![]() |
In this section, you'll create a simple web method (a method that can be invoked over the web) in the web service. This operation is designed to return customer data. In a real world application, this method would probably perform some database lookups. In this simple example, your service will simply return the name "John Smith" to all customer enquiries.
Before you start, be sure that Workshop has MailingListService.java open for editing in the Design View. To ensure that the file is open for editing, double-click on MailingListService.java in the Project Explorer view.
At this point, the method will be marked with red-underlining, indicating
a compile error. In the next step, you will correct that error.
return "John Smith";
The final method should appears as follows:
@WebMethod public String getCustomers() { return "John Smith"; }
In Source View, the class should now look like this:
package services; import javax.jws.*; @WebService public class MailingListService { @WebMethod() public String getCustomers() { return "John Smith"; } }
In Design View, the class should look like this:
Click one of the following arrows to navigate through the tutorial:
![]() ![]() |