Community in read only mode June 18 & 19
This community will be set in READ ONLY mode for a while on Tuesday June 18 into Wednesday June 19 while we import content and users from our Micro Focus Forums community site. MORE INFORMATION
Highlighted
Charan2 Absent Member.
Absent Member.
5981 views

Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Hi 
Our Objective is to consume the WCF Service Created in .NET 4.5.

We are trying to Consume the Same WCF Service in Visual COBOL.

As per my initial understanding, To achieve this in Visual COBOL, We have couple of questions:

1.  Can we consume the WCF Service(.NET 4.5) in NATIVE project created in Visual COBOL?

      If Yes ?  Then how to do that? Some Example of thread will help us.

2. Can we consume the WCF service(.NET 4.5) in Managed project created in Visual COBOL?.

    If Yes ? Then How? Some Example or thread will help us.

Thanks

Charan

0 Likes
2 Solutions

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

I do not know of another way to consume the WCF service other than the two approaches you mention here.

I have added an example to your other posts which shows how to get the COM approach working.

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

The userid and password fields if specified, will be passed as part of the SOAP message in order to do basic Web Service authentication if your Web Service supports this.

If you do not require basic authentication then these can be ignored.

0 Likes
15 Replies
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Hi Charan,

In a native COBOL project you can consume Web Services by using the IMTK, Client Generation tool if you have a WSDL file for the Web Service. For a WCF Web Service you can obtain the WSDL by adding ?wsdl to the address of the service:

Not all wsdls are supported.

To use the client generation tool from within the IDE you would select Tools-->Micro Focus COBOL-->Generate Client From WSDL.

For managed code there is no problem. If you have a managed code project you can simply right click on the project name and select Add Service Reference and navigate to the service using it's URL if it is not on the development machine or you can use Discover to locate services that are local.

This will then generate the required class that can then be instantiated from your client code and you can call the methods on this object.

There are a number of examples in the Samples Browser for WCF under the category Windows Communication Foundation in the left hand window.

There is also a tutorial in the docs for WCF here:

Thanks.

0 Likes
Charan2 Absent Member.
Absent Member.

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Hi Chris,

Thanks for the reply.

Consuming WCF from Visual COBOL managed Code is clear to me and I am able to consume the WCF from Managed Code.

For Native Code i have used the Tools-->Micro Focus COBOL-->Generate Client From WSDL option.

I need an WSDL file as input to generate the Client.

There are two types of WCF I have to consume in Native Code.

1.  .NET WCF which are hosted with HTTP protocol , I am able to get the WSDL file after appending ?WSDL in the URL.

And then used the option to generate the Client from WSDL,  It generates an application with 3 components in it :- Proxy COBOL program, Copybook and Application Program to call the Proxy COBOL program.

And when i run it it works fine and able to make a call to .NET WCF and get the output.

2. .NET WCF which are hosted with TCP/IP protocol, In this case I am not able to get the WSDL file after appending ?WSDl in the URL.

By making some changes at .NET WCF's config file we are able to generate the WSDL file.

Then I have generated the Client using WSDL, It generates 3 components same as above,

But when I try to run it , it is asking for Service address and when i provide the Netcp address its not able to make a call to WCF and i am getting error code "0017 - No User data after transformation".

Let us know your thoughts for the same and where we are making mistake.

Regards,

Charan

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

It doesn't sound as if the WSDL generated by (2) above created a valid client. As I stated earlier, the native client generation does not work with all WSDL files especially those from WCF services. If you cannot generate a native client but you can generate a managed client then you might look at calling the managed client from the native program through COM Interop.

To test that the WSDL itself is valid you should download a tool such as SoapUI and import the WSDL there and try to run its client. If it works in SoapUI then it should probably also work in our client generator and then we could look into possible differences. If it also doesn't work in SoadUI then there is most likely a problem with the WSDL itself.

0 Likes
Charan2 Absent Member.
Absent Member.

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Yes Chris,

It seems there is some problem with the WSDL for TCP/IP Hosted WCF. I will see if that can be corrected.

Apart from using Generate the Client using WSDL option and  Using WCF in Managed Code and calling it from Native program VIA COM Interop.

Is there any other way to consume the WCF in Native Code ?

Let me know if there is any other option to consume WCF in Native Code.

Thanks a lot.

Charan

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

I do not know of another way to consume the WCF service other than the two approaches you mention here.

I have added an example to your other posts which shows how to get the COM approach working.

0 Likes
Charan2 Absent Member.
Absent Member.

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Thanks Chris!!!

0 Likes
Charan2 Absent Member.
Absent Member.

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Chris,

I am able to successfully consume WCF in the Native code Via Generate Client Using WSDL tool.

There are two COBOL programs and One Copybook is created using WSDL.

The Proxy Program which contains the Entry point for all WCF methods.

The Application program to consume the Proxy and Copy book to interact with WCF.

I have a small query regarding two Entry Point present in Proxy Program.

There are two Entry Points for set User ID and Password. What is the purpose or use of those two Entry points.

Because those are optional ...If we don't provide any password or user id, We are still able to call the wcf service and proxy program is able to make a call to WCF methods.

So what is the purpose of them and when we should use it.

Please let us know about the same.

Thanks

Charan

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

The userid and password fields if specified, will be passed as part of the SOAP message in order to do basic Web Service authentication if your Web Service supports this.

If you do not require basic authentication then these can be ignored.

0 Likes
Charan2 Absent Member.
Absent Member.

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Thanks Chris!!!

0 Likes
Renato Absent Member.
Absent Member.

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution
Please there is some example of how to consume webservice, I use visual cobol for visual studio 4.0.
Thank you
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution

Hi Renato,

What type of Web Service are you trying to consume?

There is a demo in the Samples Browser of consuming a WCF Web Service. Look under Managed Code-->WCF-->WCF Airport Demo.

There is also a tutorial that you can run thru here:

0 Likes
Renato Absent Member.
Absent Member.

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution
I need to transmit a Signed XML to an autarchy, and wait for the answer, but to connect in that autarchy I need to use the same digital certificate. I already do this in NetExpress 3.1, however I can not use the digital certificate to connect, as we are migrating to Visual Studio for visual cobol I am already thinking and doing for that version. but I found nothing about it.
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution
Are you sure you want to use WCF? Is the web service you're connecting to actually a WCF service?

You may want to review this discussion:
community.microfocus.com/.../
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Consuming a WCF Service Created in .NET 4.5 in Visual COBOL.

Jump to solution
In another topic, Renato asked: "today I already sign the XML with digital certificate using a .NET class and I have a program in NetExpress 3.1 that does the transmission, however, when I will transmit the XML to connect in the Web Service I need the same digital certificate".

The .NET Framework HttpWebRequest class supports TLS and lets the client set the client certificate. Use WebRequest with an "https" URL to create the HttpWebRequest object, cast it to the HttpWebRequest type, and set its ClientCertificates property to an X509CertificateCollection containing your certificate. You should be able to find examples online.

It's also possible to do this with the newer HttpClient and HttpRequestMessage classes, but it requires creating an HttpRequestHandler and (in managed COBOL) using the ContinueWith method and a delegate, as shown in Ted John's method in the other topic. I don't recommend this approach.
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.