Consuming WCF in NAtive Code via Managed Code in Visual COBOL

Hi Chris,

The objective is to Consume the WCF Created in .NET 4.5 in Visual COBOL.(In Native Code VIA Managed Code)

To Do this I have followed following Steps:

1. Created an Managed Project in Visual COBOL, Added the Service Reference of .NET WCF. 

2. Selected the Property of Managed project as "Register for COM Interop". I am getting couple of Warning for the same. (Type Library exporter warning Generic Code may not exported to COM.)

3. Created an managed program to create an object of WCF Client Class and call the WCF methods.

3. Created an Native Project and added a Native Program.

4. Provide the Class Control section to point to the OLE object created by Managed Project.

5. Tried to Invoke the Managed Program of Managed Project from Native Program.

I am able to reach to the Managed Program (getting a display from there) But when managed program tries to call the WCF method , I am getting following error " Could not find the default endpoint element that references the contract "IService1". in the service model Client Configuration Section.

this might be because no configuration file was found for your application , or because no endpoint element matching this contract could be found in the client element".

Hope you are able to understand the problem, Let me know if you require any additional info. 

Let us know what can be possible problem in this approach.

Regards,

Charan

Parents
  • Thanks Chris!!! I was able to solve the problem.

    It was related to the type of parameter passed (By Ref, By Value). Was wrongly passing by Value data type as By reference.

    I have one more query for the example you provided to me in the above thread to handle EndPoint error.

     class-id WcfCOMTest.Class1.

          working-storage section.

          method-id callWCFTest.

          local-storage section.

          01 wcfservice type ServiceReference1.Service1Client.

          01 remoteAddress type System.ServiceModel.EndpointAddress value new System.ServiceModel.EndpointAddress("localhost/Service1.svc").

          procedure division using by value theValue as binary-long

                             returning theString as string.

              set wcfservice to new ServiceReference1.Service1Client(new type System.ServiceModel.BasicHttpBinding(), remoteAddress)

              set theString to wcfservice::GetData(theValue)

              goback.

          end method.

    in the example above you have hard coded the endpoint address as "localhost/Service1.svc"

    and while creating the object of Service1Client we have provided the (Binding and remote address) parameters.

    here we are using the one constructor of Service.

           public Service1Client(Binding binding, EndpointAddress remoteAddress) :  {  }

           public Service1Client (string endpointConfigurationName) :  {  }

          public CalculatorClient(string endpointConfigurationName, string remoteAddress) :  { }

         public CalculatorClient(string endpointConfigurationName, EndpointAddress remoteAddress) : { }

    Is there a way where we can use the second consturctor and avoid using the hard coded http address?

    we want to use the second constructor by providing only endPointConfigurationName parameter. but not sure how to do it and it will work or not.

    Rgerads,

    Charan

Reply
  • Thanks Chris!!! I was able to solve the problem.

    It was related to the type of parameter passed (By Ref, By Value). Was wrongly passing by Value data type as By reference.

    I have one more query for the example you provided to me in the above thread to handle EndPoint error.

     class-id WcfCOMTest.Class1.

          working-storage section.

          method-id callWCFTest.

          local-storage section.

          01 wcfservice type ServiceReference1.Service1Client.

          01 remoteAddress type System.ServiceModel.EndpointAddress value new System.ServiceModel.EndpointAddress("localhost/Service1.svc").

          procedure division using by value theValue as binary-long

                             returning theString as string.

              set wcfservice to new ServiceReference1.Service1Client(new type System.ServiceModel.BasicHttpBinding(), remoteAddress)

              set theString to wcfservice::GetData(theValue)

              goback.

          end method.

    in the example above you have hard coded the endpoint address as "localhost/Service1.svc"

    and while creating the object of Service1Client we have provided the (Binding and remote address) parameters.

    here we are using the one constructor of Service.

           public Service1Client(Binding binding, EndpointAddress remoteAddress) :  {  }

           public Service1Client (string endpointConfigurationName) :  {  }

          public CalculatorClient(string endpointConfigurationName, string remoteAddress) :  { }

         public CalculatorClient(string endpointConfigurationName, EndpointAddress remoteAddress) : { }

    Is there a way where we can use the second consturctor and avoid using the hard coded http address?

    we want to use the second constructor by providing only endPointConfigurationName parameter. but not sure how to do it and it will work or not.

    Rgerads,

    Charan

Children
No Data