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

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.



  • 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:


  • 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.



  • 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.

  • 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.


  • Verified Answer

    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.

  • 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.



  • Verified Answer

    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.

  • Please there is some example of how to consume webservice, I use visual cobol for visual studio 4.0.
    Thank you