Absent Member.
Absent Member.
851 views

Call from WCF TO COOBOL

HI,

Scenario:

I have to call COBOL program from my WCF/WCF REST.

I have created a wcf and wcf rest project and incorporated my C# code in the interface implementation. However its failing to call COBOL and getting results.

The C# code to call cobol is working fine when call from console application. Same code is not able to call from WCF.

Kindly let me know how do I call COBOL (C# code exists and working in console) from WCF REST or WCF.

Am new to WCF and COBOL. Kindly give some inputs.

Thanks,

Manasa

0 Likes
1 Reply
Micro Focus Expert
Micro Focus Expert

If you are trying to call a procedural COBOL program from a C# program running as a WCF service then you should do this by creating a RunUnit in C# and then calling the COBOL program within the RunUnit.

Please see the documentation here

This will direct you to open up the file MicroFocus.COBOL.RuntimeServices.chm, which is installed in the Help folder of your installation. Within this help file are examples of how to call COBOL using the RunUnit class from C#.

.Example:

Create a run unit for the called COBOL program
MicroFocus.COBOL.RuntimeServices.RunUnit myRunUnit = 
      new MicroFocus.COBOL.RuntimeServices.RunUnit();
 try
 {
   // Call the COBOL program
   result = myRunUnit.Call("Program1", "Alice", 21);
   result2 = myRunUnit.Call("Program2");
 }
 finally
 {
   // Destroy the run unit
   myRunUnit.StopRun();
 }
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.