You need to do the tutorials in this book in the order shown by the Tutorials Map.
In this chapter, you use the Generate Client feature in Net Express to generate a COBOL proxy program that can be used as a client to a particular Web service. You can call the generated proxy from a sample COBOL application that is generated with the proxy, or from your own client application. The proxy receives data from the calling application, invokes the Web service and returns any data back to the application.
Although clients communicate with Web services across the Web, this does not mean the client has to have a Web-type interface. The client application that is generated with the proxy is a simple character-mode application that uses ACCEPT/DISPLAY statements for its user interface.
In the chapter Deploying a Service, you deployed a Web service called wmapserv. In this chapter you create and run a client application that uses wmapserv.
Minimize your Web browser and the console daemon. If the Net Express IDEService Interfaces window is minimized, restore it.
If Net Express, the project Mapdemo, and the Service Interfaces window aren't open, open them now - to open the Service Interfaces window, click File > Open Service Interfaces, then select mapdemo.mpr from Examples\Net Express IDE\mapdemo and click Open.
If the Service Interfaces window isn't open, open it now, using the command:
cobimtk
Make sure the ESDEMO enterprise server is started and the wmapserv service is deployed in it, as described in the chapter Deploying a Service.
The Interface Mapping Toolkit provides two ways you can generate a COBOL client for a Web service. The more general way is to generate directly from the Web service’s WSDL file. This can be done for any Web service that you have the WSDL file for. Thus you can use the Interface Mapping Toolkit to generate a client for a published Web service whose WSDL file you have obtained from the Web.
When you have created and deployed a service using the Interface Mapping Toolkit, you can also generate a client from the service directly without seeing the WSDL.
In this tutorial we show both ways. There is no harm in generating twice. Alternatively, you might like to run this tutorial twice, doing it the two different ways.
To generate from the mapping:
You could alternatively right-click wmapserv and then click Generate Client. This goes straight to using the mapping without offering the choice of using the WSDL.
The proxy file wmapserv-proxy.cbl, the sample application file wmapserv-app.cbl and a copybook file wmapserv-copy.cpy are generated and added (along with associated build objects) to the project.
To generate from the WSDL:
A wizard opens.
This is the WSDL file that was created when you created wmapserv. You could use this facility to create a client for any Web service by using its WSDL file here.
Click OK on the message saying client generation has completed.
Type 3 (for a Read operation), and press Enter.
Note that the code for Read is not the same as the code used in book.cbl and the service. A client knows nothing of the internal workings of the service.
In response to the prompts, type 1111 for the stock number, and leave the title and author blank. Press Enter after each one.
After a few moments, the client displays the name and content of each field from the requested record. It has successfully called the Web service, which has looked up the record in the file and returned the data.
If you run this tutorial twice, generating once from the mapping and once from the WSDL file, you may notice minor differences in the behavior of the generated client. When you generate from the mapping, the picture-strings in the client are based directly on those in the original legacy program. When you generate from the WSDL, this direct link is not available, and the picture-strings in the client are based on the data types in the WSDL.
Try a few more operations. Recall from the chapter Creating a Service that the file as supplied contains records 1111 and 2222, and you may have added a record yourself - number 4444 if you used the example data suggested in that chapter.
To see how to debug this service, continue at the chapter Debugging a Service.
If you want to take a break first, you can close Net Express and/or the project.
Copyright © 2006 Micro Focus (IP) Ltd. All rights reserved.