Chapter 2: COBOL Web Services with the Interface Mapping Toolkit

This chapter covers those aspects of the Interface Mapper Toolkit that are specific to Web services.

Overview

You can use your COBOL development system to expose a COBOL program as a Web service. The set of tools provided for this purpose is the Interface Mapping Toolkit. This can be used for the types of service that are supported: COM object, EJB or Web service - and is described in the chapter Interface Mapping Toolkit.

As the chapter Introduction to COBOL Web Services explains, there are several ways of creating COBOL Web services using your COBOL development system. The Interface Mapping Toolkit is the recommended route, because together with Enterprise Server it provides a complete, purpose-built solution. For a detailed comparison of the alternative routes, see the chapter Application Extension with Distributed Computing.

Aspects of the Toolkit specific to Web services are:

Web Services Description Language (WSDL)

The Web Services Description Language (WSDL) is an industry-standard language that Web services use to formally describe an interface to a client accessing the interface. The Interface Mapping Toolkit fully supports WSDL, enabling clients written in any language and running on any operating system to access your Web service successfully.

Normally, you would have to be familiar with the WSDL language and create a WSDL file yourself. However, this is not necessary with the Interface Mapping Toolkit - the document is created for you as part of the deployment process. You then simply supply the WSDL document to the client.

Many software vendors provide tools that can consume WSDL documents and produce client programs in numerous languages that can work with the Web service. The Interface Mapping Toolkit provides just such a tool, described in the section Client Generation.

Client Generation

For a Web service, the Interface Mapping Toolkit includes a function to generate a COBOL client application to use the service. This application can be used as an example or starting point for writing a real client application. It consists of two COBOL programs. One program provides a simple character-mode user interface, using ANSI-standard ACCEPT and DISPLAY statements. It calls the other, which is known as the proxy. The proxy invokes the Web service.

Mapping or WSDL

When you use the Service > Generate Client option, you see two options, using Mapping and using WSDL. It's important to understand the difference.

The usual way to create a client for a Web service is from the WSDL file that describes the service. You may have downloaded this WSDL file from the Web - the service may be available on your intranet, or publicly available on the Internet. To create a client application, people usually use a software tool that reads the WSDL file and generates the client (at least, the part of it that calls the service). The Generate Client using WSDL function is such a tool.

When you deploy a Web service you created using the IDE, one of the files created is its WSDL file. You can input this to the Generate Client using WSDL function if you wish. However, this option is not designed primarily for use with a Web service you have created yourself using the Interface Mapping Toolkit.

The option designed specifically for this purpose is using Mapping. With this option, the client is generated directly from the mapping. The using Mapping option is enabled only when you have selected a Web service in the Service Interfaces window, whereas the using WSDL option is always enabled. If you right-click a Web service and use the Generate Client option on the popup menu, it goes straight to the using Mapping option.

The advantage of using Mapping is that the data definitions in the client more closely resemble those in the legacy program.

In COBOL you have very detailed control of the description of a data item, through the PICTURE clause; whereas the XML used in a WSDL file provides only a fixed set of types. When the Interface Mapping Toolkit creates a WSDL file, it assigns each interface field an XML data type compatible with the PICTURE clause of the corresponding data item, but the precise definition of the data item cannot be conveyed. Then when the client is generated, its data items are given PICTURE strings reflecting the XML types of the interface fields. Thus the data description of an item in the client is compatible with, but not necessarily the same as, that of the corresponding data item in the legacy program. But if you generate using Mapping, the data descriptions in the client are based directly on those in the legacy program.

Adding to a Project

When you generate from a WSDL file, you get a two-page wizard, on which you specify the WSDL file and then choose the project to add the client to. When you generate from mapping, you get just a dialog box corresponding to the second of these pages.

By default the client is added to the project you currently have open. If you use your projects in a straightforward way, this is the project the service belongs to. However, you can specify that the client should be added to a different project, which you may prefer if subsequent work on it is to be done separately from work on the service.

Note that the client is generated the moment you click Finish on the wizard (OK if you just have the dialog box). If you choose Use an existing project, then after clicking Finish (or OK) you get a message asking whether to continue. If you click Yes, it is added to the project you specified; if you click No, it is not added to any project. In either case the client has already been generated and saved in the project folder for the project you specified.


Copyright © 2006 Micro Focus (IP) Ltd. All rights reserved.