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

Step 2: Add a Web Service to the Project

In this section, you will add a simple web service to the project you created in Step 1 by first creating a Java package and then inserting the web service into the package.

  1. In the Package Explorer, expand ServicesWeb and right-click the src folder.
  2. Click New > Package.
  3. The New Java Package dialog box appears.

    The Source Folder text box should be prepopulated with the string ServicesWeb/src. If it is not, enter that string.

    Enter services in the Name text box and click Finish.

    Notice that a package named services is now displayed under the src directory (that is, ServicesWeb/src) in the ServicesWeb project in the Package Explorer view. Physically, services is a directory. In the following steps, you will create a web service within that services package.
  4. Right-click the services package.
  5. Click New > WebLogic Web Service.
  6. The New Web Service dialog box appears.

    Enter MailingListService.java in the File name text box and click Finish.


The preceding steps created the new Java file MailingListService.java in the services folder.

You should now see MailingListService.java in Design View.

Design View gives a graphical representation of your web service, its methods, and any controls it contains. The web service MailingListService.java has one method, named hello, and no controls. The hello method is created by default with each new web service.

To see the underlying source code for the web service, click the link text Source View at the bottom of Design View. The source code for the web service appears as follows:

package services;
 
import javax.jws.*;
 
@WebService
public class MailingListServices {
 
    @WebMethod
    public void hello() {
    }
	 
}

Note the use Java5 annotations in the source code, for example, the @WebService annotation, which specifies that the class implements a web service. Java5 annotations are used to set properties on the web service class and its methods.

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

 

Skip navigation bar   Back to Top