3

I have a WCF Service. I need to call it from C++.

The solution can be using C# dll to call WCF and calling it from the C++ code. Or C++ dll directly calling WCF Remote Service.

EDIT : I have tried importing the C# dll into C++ file with the help of the follwing Code Project article. But In my C++ file I cant import like this :

#import "tlbfile.tlb" raw_interfaces_only named_guids

ERROR Cannot open source file tldfile.tlh

EDIT 2 : I have decided to use VC++. And made a C# dll to call the Web Service. But cant refer the dll in MFC Application.

Im running on VS 2012.

Rohit Vipin Mathews
  • 11,629
  • 15
  • 57
  • 112
  • I have a C# project which communicates with a PHP project via WCF service. I have the C# project with the service and in PHP I call the wsdl. Take a look at this: http://stackoverflow.com/questions/15254251/how-do-i-consume-wcf-service Maybe this will help you out. The webservice generates a WSDL, and then you need to call the WSDL in your C++ project. – Matheno Aug 20 '13 at 08:52
  • 1
    Have you looked at this? http://stackoverflow.com/questions/686452/create-wcf-service-for-unmanaged-c-clients – The other other Alan Aug 20 '13 at 12:58
  • @user1467261 Yes.The answer is really good. – Rohit Vipin Mathews Aug 28 '13 at 10:21

1 Answers1

3

As some of the above mentioned that the WCF exposes WSDL. Which is platform independent. You can use any of the ways you mentioned.

1: Create C# client as library(dll) and use that dll in C++ code using interoperability. But this is tedious process as Interoperability is tedious.

2: Create direct C++ client:

 A. Create C++ proxy class from WSDL file
 B. Use that proxy class in your Code for communicating with Server. You will have to maintain Channel opening and closing.

3: Use third party libraries to handle communication channel. One of the best library is POCO. Poco Library for C++

mateuscb
  • 10,150
  • 3
  • 52
  • 76
Jeet
  • 91
  • 2