|
By Kathy Chan
August 11, 2005
|
Introduction |
|
|
|
This document is one of a series of tutorials to
demonstrate the use of the Web Services tools in the Web
Tools Platform Project using the WTP 0.7 drivers.
|
|
This tutorial shows how to create a simple top-down Web
service from a WSDL file. The WSDL file in this scenario
calculates the area of an rectangle.
|
|
|
Set Up |
|
|
|
Before creating the Web service, there are three
prerequisites:
-
Install Apache Tomcat
-
Set the J2EE Project Module Preference to
allow multiple modules per project. Open
Window -> Preferences... -> J2EE Project Modules Preference
and check the Allow Multiple modules per project option.
- Create a Web project
-
Open
File -> New -> Other... -> Web -> Dynamic Web
Project
to create a new flexible project and Web module.
- Click Next.
- Add a new project by clicking New... beside the project name field.
-
Enter
AreaProject
into the
Name
field.
-
Ensure that the
Target server
is set to
Apache Tomcat v5.0
. If you have not previously configured
a server runtime use the New...
button beside the Target server field to
do so. Result:
- Click Finish to go back to the Dynamic Web Project wizard.
-
Enter
area
into the
Module Name
field. Result:
-
Click
Finish.
-
Say Yes to open the J2EE perspective and you will
see the AreaProject you created listed
under Dynamic Web Projects in the Project Explorer
view. Expand the AreaProject project to
see its contents.
|
Create a top down Java bean Web service |
|
-
Import the file
AreaService.wsdl
into AreaProject/area/WebContent.
- Select the AreaService.wsdl file.
-
Open File -> New -> Other... -> Web Services -> Web
Service.
- Click Next
-
In the Web service type combo, select
Top down Java bean Web Service
.
-
Select
Overwrite files without warning
. Result:
-
Click
Next
. Result:
-
Click
Next
to get to the
Service Deployment Configuration Page
. Result:
-
If you want to choose a server different
from the one defaulted by the wizard, click the
Edit
button to:
select a server
-
Click
Finish.
-
It will take about one minute for the wizard to assemble
the Web service projects, start Apache Tomcat and deploy
the projects to Tomcat. Once finished, the Java
implementation file
AreaServiceSOAPImpl.java
will appear in the browser view. Fill in the expression
parameters.getHeight()*parameters.getWidth()
as the return value for the calculateRectArea method and save the file.
|
|
Follow the instructions at
Creating Web Service Client
to create a Web service client that you can then use to test this Web service.
|