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

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

Related

Creating a SOAP client in C++ (VS 2010) without any third party library like gSOAP

We need to make SOAP requests in C++. Basically a SOAP client. The catch is that we DON'T want to use any third party library like gSOAP. Reason being that the transactions are finance related. We need to write the complete code ourselves.
Please suggest ideas towards it. I believe that this is going to be very complex.
Any ideas towards this would be of great help. Our environment is C++ on windows (VS 2010) Please note that for now, we can assume that there is a single SOAP based web service (written in C#) for which we need to do it. Therefore, any complexity related to generalizing this SOAP client can be left out for now.
Ultimately a SOAP request is a HTTP POST of XML data. You can build the XML yourself and use IWinHttpRequest to post that data to the server.

Supporting Web Services from a Win/MFC/C++ App

I am looking for the best way to add support for a REST based Web Service to an MFC C++ Application. This is legacy code that has been around a long time.
I need to have the Application provide the Web Service. I've researched this, and the articles are about consuming Web Services in a C++ App. I envision having to monitor a port and respond to the HTTP requests. It would probably make more sense to tie in with WCF and IIS, but I am not sure how to move forward.
I already have a tool of "making" this App into a Windows Service. I realize it would be better to have a "real" app, and this is what I have to work with. There is so much logic in this code and we are limited in development time, so we are taking the fastest approach possible. We also cannot use DCOM, as the Web Service will be called by a Linux based system.
Any suggested articles would be much appreciated.
For C++ you can test two libraries WSF/C and gSoap, another alternative is to develop it with C# and WCF , and communicate between C# and C++ using C++\CLI.
I use the Poco Net c++ library for this as it supports both HTTP client and server functionality. I considered various other libraries including Boost based stuff, but other than Poco I struggled to find everything I needed in one tidy package. It also has some easy to use mutex support which became essential for me as soon as I added a web server front-end to what had previously been a simple single threaded console app. Poco is cross platform but I mainly use it windows and it has served me well to date. I'm not very clued up on MFC so I don't know how it would get on in that department though.

Access Exchange Mails using EWS without C# code?

Is there a way I can access the Exchange Mails/Calendars/Addressbook without .NET or non cross platform thing? I want to access them with C++ but on both MS and Linux. Their docs says it is possible but there is no any non C#/.Net example.
EWS combines the functionality that is included in WebDAV and CDOEX, and provides logic that makes common scenarios such as calendaring workflows easy to implement. EWS is a SOAP-based XML Web service that can be accessed remotely from any operating system and any language that can send requests over HTTPS.
Please share with me if there is any way or I'm missing something!
Thanks!
I agree that there are few examples outside the C# / Powershell realm. That being said, if you stick to plain EWS, it should be possible. I have no idea the WebServce access from C++ is anything similar to C#. In C# you point Visual Studio (or wsdl.exe) to the WSDL of the WebService and it will create a set of proxy classes which do all the SOAP handling.
If you don't have something similar with C++ you'll need to build the SOAP requests yourself.
See http://msdn.microsoft.com/en-us/library/bb204119(v=exchg.140).aspx for a reference to the EWS operations and XML elements.
One thing you might want to utilize is the EWS Managed API. It has a nice tracing feature which dumps all the requests/responses to the console. So, you can write up a small test program and see what the request has to look like. This could help you building the EWS requests on the C++ side.

Lisp soap client

It was very easy to use Apache CXF to develop a client for a SOAP web service. All I had to do was call wsdl2java and all the required classes were present. Is there such a client for lisp? If not, what can I do to write a soap client for lisp? The only restriction is that I don't have access to commercial implementations such as franz/lispworks or macs.
There's CL-SOAP which I tried earlier this year. The nice thing about it is that it can read a WSDL file and use that to generate the client proxy. I couldn't get it to work against my SOAP service, and gave up that attempt at some point (I used SBCL). CL-SOAP itself feels a little abandoned, with the last update dated 2005. It might work for you out of the box. If not, the code is straightforward and may do what you need with some modification.
CL-XML is said to have a "SOAP module", which I didn't try out.
The question appears to be asked periodically on comp.lang.lisp, with more-or-less similar answers. You may find more pointers there.
Allegro Common Lisp has both a SOAP server and a SOAP client. I've used both with success, and they're currently maintained and supported (unlike CL-SOAP).
My SOAP server easily handles a few hundred requests a second (from both Java and .NET clients), so I'm happy with the performance.

Can WSDL 2.0 (or similar) be used to generate a web service boilerplate?

I apologize if if this is a bonehead question.
I've used WSDL to generate code to talk to web services, but my question is about using it to actually generate web services.
Let's say that I have a device that is going to communicate with a web service. The web service in question doesn't actually exist and is out of my control. That is, the party wishing to process messages from my device must implement the service.
The service in this case is extremely basic. It's simply a small collection of methods that receive messages and return status codes. It's basically a middleman between my device and 3rd party software.
It would be really cool if I could supply something like a WSDL 2.0 document that they could then use to actually generate the boilerplate code for the service and methods they are required to implement...preferably in Java (Axis) and .NET friendly frameworks.
In other words, I want to use WSDL to generate the service, not the client. Or maybe I don't want WSDL at all. What techniques would you recommend to make this as painless as possible?
SvcUtil.exe for the Windows Communication Foundation technology in .NET 3.0+ can do some of what you're asking, i.e. generation of contract interfaces and basic client code using a predetermined WSDL as input.
Now, this will not fully generate the actual service, just the contract interface. I don't know of an easy way to do this as it is probably not a very common case. Essentially what you're asking is a slightly more automated version of what Visual Studio does when you create a class and use the "Implement interface" feature (which I believe is accomplished mostly through VS templates).