How do I create a web/wcf service client in C++?

c++, webservice-client

Solution

In the end I went with using the NSIS "Call .NET DLL methods plugin" which was really overkill for what I needed to do, but I needed a solution that worked and I ran out of time.

Problem

I'm using NSIS to build an installer and as part of that installer I get the details for a WCF Service (i.e. Url, User Name and Password). I need to validate these details. In C# I create a Service Reference and simply do the following: ``` var proxy = new ServiceClient(httpsBinding, serviceEndpointAddress); proxy.ClientCredentials.UserName.UserName = userName; proxy.ClientCredentials.UserName.Password = password; try { proxy.Open(); } catch (EndpointNotFoundException ex) { // Return the end point's not valid } etc ``` Now I need to do this in C++ so it can be called from NSIS (I've investigated methods of calling C# from NSIS and they all seem to be overkill for what I want to do). I've managed to convert the code that generates the binding and the end point address however I'm stuck on creating the `ServiceClient`. I've added a "Web Reference" to the project but there's not the equivalent of `ServiceClient` in the `ServiceReference` namespace. This: ``` ServiceReference::ServiceClient ^service = gcnew ServiceReference::ServiceClient(httpsBinding, endpointAddress); ``` doesn't compile as: 'ServiceClient': is not a member of 'ServiceReference' So how do I create the client?

Original source