Creating a Client Web Service Using eXtend Workbench from a Web Services Description Language Document
Articles and Tips: tip
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.
Create a new project in Workbench by selecting the File menu > New Project.
Fill in the information necessary, such as the path to create the project.
From the File menu, select New .
From the New File window, select the Web Services tab. Select Existing WebService. Click OK .
In the Web Service Wizard window, type the following URL into WSDL file or URL to use:
Click Next .
In the next window, supply the following information:
Use the default for the "Root directory for generated objects."
Leave Generate stubs checked and check the Verbose mode.
Type temp in Specify the package for generated files.
Click Finish .
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.
Un-comment the println() method and replace the java.lang.String entry with args. 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));
Save the project. Compile by running the Build and archive command.
To test your client, perform the following steps:
From the Project menu, select Run Web Service Client Class .
Select temp.Temperature_CLIENT as the Client Class to run.
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
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.