After creating the project, you can create your web service. To create a web service, you need to complete the following steps:
- Right-click the TestApp project in the Projects tab.
- Select Web Service from the New option. This opens the New Web Service dialog box.
- Specify a name for your web service in the Web Service text box. For example, HelloServer.
- Enter com.example in the Package field.
- Select Create an Empty Web Service and click the Finish button. At this stage, your web service is compiled and created.
- You now need to add operations to your web service. In the Projects tab, expand the Web Services node.
- Right-click the HelloServer web service.
- Select Add Operation. This opens the Add Operation dialog box.
- Specify a name for the method in the Name text box. For example, type display.
- Specify the return type of the method in the Return Type drop-down list. For example, select String.
- Next, in the Input Parameters and Exception section, click the Add button under the Parameters tab to define a parameter for the method defined earlier. For example, type name.
- Click OK to proceed.
- Next click OK in the Add Operation dialog box. This creates the operation skeleton. You can find the created operation by expanding the com.example node under the Source Packages node within your TestApp project.
- In the HelloServer.java file, which is an implementation file, fill out the operation skeleton. Replace the code contained in the body of the HelloServer operation as demonstrated.
|