Novell is now a part of Micro Focus

Creating a Client Web Service Using eXtend Workbench from a Web Services Description Language Document

Articles and Tips: tip

Jeff Fischer
Research Engineer
Novell, Inc.
jfischer@novell.com

01 Jun 2003


Note: This is a section from the DeveloperNet University course found at http://developer.novell.com/education/tutorials/web/.

Web services are the newest category in software development. They combine the flexibility of loosely coupled systems with the robustness of open standards. Web services offer a great architecture and software platform to exchange data between remote applications and software modules. Web services are increasingly being used for business-to-business transactions, as well as for consumer-focused web applications because of their ease of creation and non-proprietary structure.

Like good object-oriented programming, one main concept of a service-oriented architecture is that the particular service you need could already be developed and deployed on a server somewhere in the world. The advantage is that you can leverage the already developed code as part of your own application.

A web service can act in two roles: producer and consumer. A producer application hosts web services for others. It has built into itself all the business rules it needs to produce the requested operations. It also has access to a datastore, such as a eDirectory or a database where it will retrieve the information it needs to fulfill the operations it needs.

A consumer application is a client application to a producer. It will make requests of a producer application and send them via SOAP. The producer application will receive the requests from the consumer, process them, and reply back to the consumer application. The consumer application will then present the data to the user.

Web Services Description Language

Web Services Description Language (WSDL) is a markup language used to describe the specific operations that a web service can perform. A WSDL document is an XML document with defined elements that represent the operations of a web service.

When a client application wants information about a web service that can perform the operations it wants, the client application will request a WSDL document that has the operations it needs. Also, if you want to build a client application for a specific web service, all you need is the WSDL document of the web service and you can build a simple consumer application for that web service.

Novell eXtend is a Visual Integrated Services Development Environment. Using Novell eXtend, you can develop you own web applications and integrate your applications with other applications.

You can use Novell eXtend to build consumer applications. All you need to do is specify the WSDL document and Novell eXtend will create all the methods you need to run the application. You can do this in a matter of minutes and in just a few easy steps. Follow the steps below to use a WSDL document on the Internet for a web service to create a simple consumer web service application.

Since we are only going to Consume a Web Service, we only need produce the Client and the Stubs that the client will use to connect jBroker Web to the Web Service. We will use eXtend Workbench to do this so eXtend Workbench and jBroker Web should be installed.

  1. Create a new project in Workbench by selecting the File menu > New Project.

  2. Fill in the information necessary, such as the path to create the project.

  3. From the File menu, select New .

  4. From the New File window, select the Web Services tab. Select Existing WebService. Click OK .

  5. In the Web Service Wizard window, type the following URL into WSDL file or URL to use:

    http://www.xmethods.net/sd/TemperatureService.wsdl
  6. Click Next .

  7. In the next window, supply the following information:

  8. Use the default for the "Root directory for generated objects."

  9. Leave Generate stubs checked and check the Verbose mode.

  10. Type temp in Specify the package for generated files.

  11. Click Finish .

  12. The workbench creates stubs and a test client file. At this point, double-click on the test client file called Temperature_CLIENT.java in the WebServices\src\temp directory.

  13. Un-comment the println() method and replace the java.lang.String entry with args[0]. This will allow you to enter in any zip code on the command line, and have the service return the current temperature in that area.

    System.out.println("Test Result = " + remote.getTemp(args[0]));
  14. Save the project. Compile by running the Build and archive command.

To test your client, perform the following steps:

  1. From the Project menu, select Run Web Service Client Class .

  2. Select temp.Temperature_CLIENT as the Client Class to run.

  3. Enter the a zip code, such as 01821, or any other zip code, into the Arguments field. Click Run .

The result should be similar to what you see in Figure 1.

The argument calls the temperture services through the WSDL and displays the information in a box.

* Originally published in Novell AppNotes


Disclaimer

The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Micro Focus