creating web services for legacy cobol craig a. vanlengen john d. haney college of business...

23
Creating Web Services for Legacy COBOL Craig A. VanLengen John D. Haney College of Business Administration Northern Arizona University Nex t

Upload: bryan-hill

Post on 30-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Creating Web Services for Legacy COBOL

Craig A. VanLengenJohn D. Haney

College of Business AdministrationNorthern Arizona University

Next

Next

Research Objective

To place a “legacy” COBOL program into a Web Service

To reference, and use, the Web Service from Windows Application Web Application

Next

Development Environment

Microsoft Visual Studio .NET 2003 MicroFocus NetExpress

Next

Function of the “Legacy” Program

Update an Indexed Sequential Master File, in batch mode Add records Change records Delete records Provide a completed message

Transactions are provided in a transaction file

Next

Interaction of Client with the Web Service

The Client provides the name of the transaction file to the Web Service.

The Web Service returns: A count of records Added A count of records Changed A count of records Deleted A completion message

The Client displays the counts and the message.

System Overview

Next

Next

Required Changes to “Legacy” Program

Linkage Section.01 lnk-FileName Pic X(80).01 lnk-addCount Pic 9(6).01 lnk-chgCount Pic 9(6).01 lnk-delCount Pic 9(6).01 lnk-txtMessage Pic x(50).

Procedure Division using lnk-FileNamelnk-addcountlnk-chgCountlnk-delCountlnk-txtMessage.

Exit Program.

Move lnk-FileName to 400-FileName.

Move 400-Add-Count to lnk-addCount. Move 400-Chg-Count to lnk-chgCount. Move 400-Del-Count to lnk-delCount.

Move "Update completed successfully!" to lnk-txtMessage.

Next

Proxy or Wrapper Class

CLASS-ID. cblProxy As "cblProxy". REPOSITORY. CLASS StringClass As "System.String" CLASS dataObject As "dataObject“ . STATIC. DATA DIVISION. PROCEDURE DIVISION. METHOD-ID. CallUpdateProgram As "CallUpdateProgram". Local-Storage Section. 01 lo-DataIn. 05 lo-FileName Pic X(80). 01 lo-DataOut. 05 lo-Message Pic X(50). 05 lo-Added Pic 9(6). 05 lo-Changed Pic 9(6). 05 lo-Deleted Pic 9(6). LINKAGE SECTION. 01 lnk-FileName Object Reference StringClass. 01 lnk-dataObj Object Reference dataObject. PROCEDURE DIVISION Using by value lnk-FileName Returning lnk-dataObj. SET lo-FileName to lnk-FileName. CALL "cblUpdate" USING lo-FileName lo-Added lo-Changed lo-Deleted lo-Message .

Invoke dataObject "New" Returning lnk-DataObj. Set lnk-dataObj::"ReturnMessage" to lo-Message. Set lnk-dataObj::"ReturnAdded" to lo-Added. Set lnk-dataObj::"ReturnChanged" to lo-Changed.

Set lnk-dataObj::"ReturnDeleted" to lo-Deleted. END METHOD CallUpdateProgram. END STATIC. END CLASS cblProxy.

Next

Data Object Class

Identification Division. Class-id. dataObject As "dataObject".

Environment Division. Configuration Section. Repository. Class DecimalClass as "System.Decimal" Class StringClass as "System.String" . Object. Data Division. Working-Storage Section. 01 ReturnMessage

Object Reference StringClass Property as "ReturnMessage".

01 ReturnAdded Object Reference DecimalClass Property as "ReturnAdded". 01 ReturnChanged Object Reference DecimalClass Property as "ReturnChanged". 01 ReturnDeleted Object Reference DecimalClass Property as "ReturnDeleted". End Object. END CLASS dataObject.

C# Client Code

Next

private void btnUpdate_Click(object sender, System.EventArgs e){ COBOLWSClient.localhost.cblUpdateServ myUpdate = new COBOLWSClient.localhost.cblUpdateServ(); updateAdded = Convert.ToInt32(myUpdate.CBLUPDATE(strFileName, out updateChanged, out updateDeleted, out retMessage)); txtAdded.Text = Convert.ToString(updateAdded); txtChanged.Text = Convert.ToString(updateChanged); txtDeleted.Text = Convert.ToString(updateDeleted); txtMessage.Text = Convert.ToString(retMessage);

btnUpdate.Enabled = false;}

Visual Studio with the Windows Client

Next

Add Reference Dialog

Next

Add Web Reference - Web Service

Next

Execution of the Windows Client

Next

Interface Mapper

Next

The Interface Mapper generates an input and output field for each field that will interact from the COBOL program.

Enterprise Server Administration Tool

Next

The Web Service is deployed using the Micro Focus Enterprise Server.

Deployment Settings

Next

Set the Web Service deployment settings.

CobolService.WSDL file

Next

- <!-- Micro Focus NetExpress 4.0 auto-generated WSDL document   --> - <types>  <schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/cblUpdateServ" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/cblUpdateServ" />   </types>- <message name="CBLUPDATEInput">  <part name="lnk_filename_in" type="xs:string" />   </message>- <message name="CBLUPDATEOutput">  <part name="lnk_addcount_out" type="xs:int" />   <part name="lnk_chgcount_out" type="xs:int" />   <part name="lnk_delcount_out" type="xs:int" />   <part name="lnk_txtmessage_out" type="xs:string" />   </message>

This file defines the web service and provides for interaction with the Web Service.

Next

Computerworld, October, 09, 2006

COBOL’s Batch Advantage COBOL: Not Dead Yet COBOL Coders: Going, Going, Gone?

Next

Computerworld, October, 09, 2006

What programming languages do you use in your organization? Choose all that apply.

 Visual Basic - 67% Cobol - 62% Java - 61% JavaScript - 55% VB.Net - 47% C++ - 47% Perl - 30% C - 26% C# - 23% Source: Computerworld survey of 352 readers

Next

Computerworld, October, 09, 2006

Cobol is a procedural language in an object-oriented world.

While it's well suited to batch operations, the language isn't as good a fit for developing interactive applications or Web-based front ends.

And it has a major image problem. Outside of the mainframe data center, Cobol is viewed . . . as an obsolete and inferior language, a vestige from the dark ages of big iron.

Next

Summary

COBOL batch programs can be placed into a COBOL Web Service and executed from a Windows or Web application.

This would fit most appropriately into high level (Senior) web development class.

Creating Web Services for Legacy COBOL

Craig A. VanLengen

John D. Haney

College of Business Administration

Northern Arizona University