Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect a C++ program to a WCF Service?

Tags:

c++

wcf

In the place I work there are some software written in C# and some written in C++ (the most important ones). Some time ago we decided it would be a good idea to track any possible problem in the software, by sending stack trace and exception information over a web service. So I came with a WCF Service, that gets the information and store them on a database and send an automatic e-mail. It worked, we had to secure it through password, it's done, but now I want our other software, the one written in C++, to use this webservice (this software is used both on windows and linux, so we can't just make a call to another software in the user machine).

I've googled about it, and found this tutorial on how to use gSOAP, which so far didn't help me very much (lots of errors, it is not very detailed, and the web.config file is impossible to read). I was wondering if is there any other way to achieve this. In adition, since I'm using authentication on my webservice, it now has a wsHttpBinding (which AFAIK isn't supported by gSOAP).

Can you guys help me out?

like image 704
Bruno Machado - vargero Avatar asked Mar 11 '11 19:03

Bruno Machado - vargero


People also ask

How do I run a WCF service?

Press Ctrl + F5 to run the service. Open WCF Test Client. To open WCF Test Client, open Developer Command Prompt for Visual Studio and execute WcfTestClient.exe. Select Add Service from the File menu.

How do you call an endpoint in WCF?

With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.

What is WCF service in C#?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another.

How use WCF service in Windows form application?

Reference the WCF serviceOn the File menu, point to Add and then click New Project. In the New Project dialog box, expand the Visual Basic or Visual C# node, select Windows, and then select Windows Forms Application. Click OK to open the project. Right-click WindowsApplication1 and click Add Service Reference.


2 Answers

Since your WCF service is in C# with .NET, and the only issue is getting the C++ application to be able to talk to it, one way is to follow the advice in REST / SOAP Endpoints for a WCF service and related articles.

Your C# programs continue to have the full SOAP access to your service. Your C++ programs could do something like this for REST access:

  • "Browse" to the HTTP GET URL for the service command you wanted.
  • Then toss (or parse and use) whatever response came back.

It is a pretty minimal change to your WCF service to offer both SOAP and REST. The REST ability opens your service to JavaScript as well as C++ clients.

You may need to restrict the interface to simple data, or class objects that are easy to parse in C++.

like image 82
Jesse Chisholm Avatar answered Nov 02 '22 18:11

Jesse Chisholm


Will the machines running the C++ applications have the .NET Framework installed?

Check out: Create WCF service for unmanaged C++ clients

like image 39
Justin Skiles Avatar answered Nov 02 '22 20:11

Justin Skiles