Highlighted
Respected Contributor.
Respected Contributor.
4500 views

Cobol consuming webservice

Jump to solution

Hello,

I have seen documents on how to create a web service from a legacy cobol program in the MF docs.

But is there a documentation on how to consume a webservice from a "standard" cobol application ? If it is possible...

For example, I would like to use some Google services like the geolocalisation to retrieve latitude and longitude from an address. We also need to call a web service running on one of our servers : it creates docx files merging the data sent from our cobol program.

Kind regards,

Alain

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

There is actually an easier method of creating a COBOL client from a WSDL/JSON file when using the Eclipse IDE. If you navigate to Run-->Tools from the IDE menu you will see the options for Generate Client from WSDL and Generate Client from JSON.

The Generate Ciient from JSON option is only available starting with our latest product release which is 2.3 update 2 which was just released this week.

Thanks,

View solution in original post

0 Likes
10 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Alain,

By "standard" COBOL application are you referring to native procedural code instead of managed .NET or JVM code? Which product do you use Visual COBOL for Visual Studio or Visual COBOL for Eclipse?

Both of these products allow you to generate a COBOL client program from either a WSDL file for a SOAP Web Service or from a JSON schema file for a REST Web Service.

If you are using VC for VS 2.3 Upd 1 then you would create a new project using the template type of Web Service Client Application from WSDL/JSON which can be found under the native category.

This will allow you to point to the WSDL or JSON file that represents your 3rd party Web Service or the output of the project will be a procedural native COBOL program and a proxy. You can then use these client programs however you wish.

You can also use the imtkmake command line tool to generate a client from a WSDL or JSON schema.

I covered some of the other approaches to this such as generating a client in a managed .NET project in an earlier post which can be found here.

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Chris,

I am sorry, I forgot to precise the environment.

We use VC 2.1 for Eclipse under Centos (RedHat).

And when I write "standard" cobol, this is indeed native procedural cobol.

A SOAP third party webservice with json (or xml) accessible via our cobol code would be the best solution for us.

Kind regards,

Alain

0 Likes
Highlighted
New Member.

There are 2 new Visual COBOL for Eclipse videos available on YouTube, related to creating Web Services from new or existing COBOL programs. The first demonstrates how to create a SOAP Web Service, and the second does the same for a RESTful Web Service.

These have been added to the Micro Focus Support and Training channel on YouTube. Here are direct links to the new videos :

Using Visual COBOL for Eclipse to Create SOAP Web Services

https://youtu.be/nTk4d4T1BG4

Using Visual COBOL for Eclipse to Create REST Web Services

https://youtu.be/ZsuWTl8eHsk

Generation of client for consuming web service is included, but not for consuming a web service created by another tool.

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

I thank you for your answer.

"nsuming a web service created by another tool" is precisely what interests me.

Is there any information on this subject ?

Kind regards,

Alain

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

You can generate a COBOL client program directly from a WSDL or JSON Schema file either within the IDEs or by using the command-line tool imtkmake with the -genclientwsdl or -genclientjson options.

For Visual Studio you can select a Web Service Client template from the list of project templates and then import your WSDL or JSON file there.

In Eclipse you would need to create a normal COBOL Project, add a dummy COBOL program to it and then use New-->SOAP Web Service or REST Web Service to the project. Point to the dummy program for the mapping.Then rignt-click on the Web Service interface and select Generate Client. This is documented here:

You can also do this from a Visual COBOL command prompt using imtkmake. This is documented here:

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Many thanks for your accurate information!

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

There is actually an easier method of creating a COBOL client from a WSDL/JSON file when using the Eclipse IDE. If you navigate to Run-->Tools from the IDE menu you will see the options for Generate Client from WSDL and Generate Client from JSON.

The Generate Ciient from JSON option is only available starting with our latest product release which is 2.3 update 2 which was just released this week.

Thanks,

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.
Thank you for the info.
I was able to follow the steps to Generate Client from WSDL but an getting compile errors:
"Cannot open file : view-source_https___api-dev.ny.gov_ManageUSDAeDRSData1.0_WSDL-app.obj"
"COBCH1641S '.' in source filename or PROGRAM-ID in native code view-source_https___api-dev.ny.gov_ManageUSDAeDRSData1.0_WSDL-app.cbl"

Any help on this is appreciated.

Thanks
Chad.
0 Likes
Highlighted
Absent Member.
Absent Member.
I got the answer for COBCH1641S error..It was because the wsdl file had many '.' preceding ".wdsl" and was causing the error.
0 Likes
Highlighted
Absent Member.
Absent Member.
Hi ,
I was able to create a client using VC Eclipse platform and when running it am getting an error 00008 "Communication Error".
The purpose is calling an external webservice.
Any help on this is appreciated.

Thanks
Chad.
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.