Rohit Vipin Mathews
Rohit Vipin Mathews

Reputation: 11787

How to call WCF service from C++

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.

Upvotes: 3

Views: 5066

Answers (1)

Jeet
Jeet

Reputation: 91

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++

Upvotes: 3

Related Questions