• No results found

Importing a WSDL

In document Web Services Developer s Guide (Page 47-51)

7 Expand the web services server node, right-click index.html, and choose Web Run Using “Web Services Server” to deploy the service to the web services server. You can also choose Run|Run Project to run the Web Services Server configuration created by the Web Services

Configuration wizard.

The service is deployed to the web server and the Axis admin page displays where you can administer, view, and validate the service.

8 Expand the package generated by the wizard, right-click the JUnit test case, <class name>ServiceTestCase.java, and choose Run Test Using Defaults to test the generated service.

Important If you make any changes to a class after you’ve exported it, you need to recompile, export as a web service again, and redeploy to the web services server for the changes to take effect.

For a tutorial which uses the Export As A Web Service wizard to export a JavaBean as a web service, see Chapter 13, “Tutorial: Creating a simple web service with Axis.” For more information about SOAP, see Chapter 3,

“Configuring projects for web services.”

Importing a WSDL

The Import A Web Service wizard generates Java classes that implement the web service defined in the WSDL. It can generate both the server-side and client-side classes for creating and consuming services. The wizard can also generate only client-side classes for consuming a service. It can optionally generate a JUnit test case to test interaction with the generated web service. You add code to the generated classes to implement the methods as desired. The Import A Web Service wizard also generates a deploy.wsdd file which provides deployment information to the web services server.

I m p o r t i n g a W S D L

Depending on the settings you select, the Import A Web Service wizard generates some or all of the following files from the WSDL. The examples for the file names are from the AddressBook.wsdl sample in

<jbuilder>/samples/webservices/axis/wsdl/AddressBook.wsdl.

Table 7.2 Files generated by the Import A Web Service wizard

File name Description WSDL element Example

complexType name.java A class for each complexType in the types section of the WSDL.

<xsd:complexType name="phone">

Address.java Phone.java

A holder class if this type is used as an inout/out parameter.

service name.java A service interface for each service which defines a get method for each port listed in the service element of the WSDL. This service

service nameLocator.java A locator class for each service which is the

service nameTestCase.java An optional JUnit test case for testing the web service.

<service name=

"AddressBookService">

AddressBookServiceTestCase.

java portType name.java An interface for each

portType in the WSDL.

binding nameImpl.java An implementation class for each portType interface.

<binding name=

"AddressBookSOAPBinding">

AddressBookSOAPBindingImpl.

java binding nameSkeleton.java An optional skeleton class

to encapsulate an

binding nameStub.java A stub class for each binding which acts as a proxy for a remote web service. This allows you to call the web service as if it were a local object.

<binding name=

"AddressBookSOAPBinding">

AddressBookSOAPBindingStub.

java

I m p o r t i n g a W S D L

The wizard generates a package name based on the WSDL target namespace or uses one that you specify, as well as adding any necessary project libraries.

The Import A Web Service wizard is available on the Web Services tab of the object gallery. You can also right-click any WSDL document in the project pane and select Import A Web Service from the context menu. The Import A Web Service wizard is also available in the Web Services Explorer when a node specifying a WSDL is selected.

To import a WSDL and generate Java classes from it, follow these basic steps:

1 Create a new project (File|New Project).

2 Create a SOAP implementation to host the web service as described in

“Working with the Web Services Configuration wizard” on page 3-1 (File|New|Web Services|Web Services Configuration).

3 Choose one of these methods to import a WSDL and open the Import A Web Service wizard:

• Add a WSDL to your project, right-click it in the project pane, and choose Import A Web Service.

• Add a WSDL to your project, select it in the project pane, choose File|New|Web Services, and double-click the Import A Web Service icon.

• Choose Tools|Web Services Explorer, browse to a WSDL, and choose File|Import A Web Service.

4 Accept Apache Axis as the toolkit and click OK.

deploy.wsdd An XML file for each

service that provides deployment information to the web services server and can be used with the AdminClient.

server-config.wsdd An XML file that provides deployment information to the server.

Table 7.2 Files generated by the Import A Web Service wizard (continued)

File name Description WSDL element Example

I m p o r t i n g a W S D L

5 Accept the WSDL URL or click the ellipsis button (..) to browse to a WSDL. Enter a user name and password if the WSDL requires one.

Click Next to continue.

6 Choose the server-side and output options you want on step 2 and 3.

Notice the package name in Package Options. This is the package where the wizard puts the generated Java class files. For more information on the Import A Web Service wizard options, choose the Help button on any step of the wizard.

7 Customize package names on Step 4 and click Finish to close the wizard.

8 Expand the new package created by the wizard to see the generated Java class files.

9 Expand the web services server node, right-click index.html, and choose Web Run Using "Web Services Server" to deploy the service to the web services server.

10Run the client to consume the service or edit the server classes to implement the service locally.

11Right-click the JUnit test case if you created one and choose Run Test Using Defaults to test the generated service.

For a tutorial which uses a WSDL document to consume a web service, see Chapter 14, “Tutorial: Generating a web service from a WSDL document.”

In document Web Services Developer s Guide (Page 47-51)

Related documents