开发者

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

开发者 https://www.devze.com 2023-02-16 02:56 出处:网络
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 softw

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?


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


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消