Calling ASMX Web Service From C++ MFC Project - c++

I have a web service that have functions to retrieve data from database. (http://exampledomain.com/webservice/webservice.asmx) It's easy to add a web service in C# (Project->Add Service Reference->Advanced->Add Web Reference) but i don't have any knowledge about C++. Also there is no option in Project tab for adding reference. How can i add web service to C++ project and access it's functions and retrieve data?

Standard C++ or MFC do no provide a way to consume web services. However, it is possible to do so with C++ REST SDK. It's a cross-platform library that allows you to consume services, use json, asynchronous streams and other things.

Related

WCF communication from c++ gSOAP or C++/CLI?

I have several unmanaged c++ programs that I use to do "heavy lifting" type operations. I like to database certain information that these clients use. In order to do this I created a WCF service which exposes my DAL to the database. I then created a managed C++/CLI wrapper to call the web service from the native C++. Would it be better to parse the WSDL using gSOAP and connect to the WCF service using SOAP?
The C++/CLI wrapper approach does have many advantages. This does make a simple way to use all of the WCF tooling, with any transport mechanism, from within C++. However, it does introduce a dependency on the CLR, which may or may not be acceptable.
Another option would be to use the C++ REST API (aka Casablanca) to call the WCF service directly, using a pure native API. This would require exposing the WCF service via REST.

Consume web service without adding service reference in C# 4.0

Is there any existing way to consume web services (SOAP, JSON, etc.) leveraging dynamic keyword from C# 4.0?
I'm looking for as lightweight implementation as possible (without calling wsdl.exe or such).
You can just share the contract (the interface) between the client and server. Then the ChannelFactory class will allow you to create communication channels to the server based on either pure code or a configuration file (app or web.config).

How to expose desktop application as a Secure Web Service?

The Window desktop application provides C++ API that gives an array of customer information such as name and address. I want to expose this as SOAP Web Service with Security so that authorized clients (from remote servers Linux/Java based through ESB) of this web service can get this information at any time they want in SOA implementation (Java based).
The desktop application does not have a standard database. It stores its data internally. Its basically old custom built CRM application that is installed on each agent's PC box. Each agent has its own list of customers.
What are the steps to achieve this task?
Do I need to run this as Windows service?
The short answer is, yes, you can expose data from a desktop application through a SOAP web service. It is easier to do with C# and .NET, but not impossible to do from C++. What steps you need to take will depend on which platform you are developing for.
Roughly -
Implement an endpoint that supports SSL where clients can connect to your desktop application (using sockets in C++ or HTTPListener using .NET).
Write code that can receive and dispatch SOAP requests.
Handle SOAP requests and return properly formatted SOAP responses.
Handle WSDL requests.
Implement a security mechanism (cookie based or otherwise).
Using .NET, most of this is in the platform code already, you just have to put the pieces together. With C++, you may find some third party libraries but essentially you'll be writing your own.
You only need to implement a windows service if you want the data to be available while a desktop user is not logged in and running your desktop application. The challenge here is that you'll have to make sure the windows service can access the same data the desktop application is using.
Another strategy would be to access the data from your desktop application using the C++ API and Interop and implement the web service as a standard out of the box asmx hosted on IIS.

WCF service with Qt?

I would like my Qt app to expose a service to another app written in .Net using WCF.
Is there any support in Qt for implementing WCF services?
AFAIK there is no 'native' Qt support for WCF or extensions; however as you know WCF can consume and expose a web service (in addition to a WCF or remoting service, etc.) All you need to do is expose it as a Web Service for the other .NET app to consume.
But that brings up an interesting aspect; usually you would write a windows service (I presume you are on Windows) which is exposed as a Web service rather than one via Qt. Qt is not ideal as it is a GUI framework (and a very good one); you will get into a few interesting situations as discussed here. It is usually easier to consume a web service with Qt as shown in this example.
Do you have the option to expose your service using some other stack such as ASP.NET or WCF or Java?

What's the best way to create a client library for a web service API?

We have web service running for one of our projects. We want to be able to access this web service similar to how you'd access an API (such as Google Data, etc.) where you have client libraries in several languages: .NET, Java, Python, etc.
You'd be able to download these libraries (usually .DLL) from our project's website and then integrate these into your custom application.
The reason we want to have these client libraries is so that we can encrypt certain data transfers between the client and the web service and so that you wouldn't have to login a million times when you want to make a request (like you have to do when using raw SOAP requests).
So, my question is... What's the best way to do this? What would the client libraries contain, other than some encryption and a bunch of methods? What's the best way to create these libraries? Obviously some different platforms are needed to accomplish this (some flavor of Linux, maybe Mac OS), should virtual environments be used?
What are your thoughts? Thanks in advance for your help!
You would first express an API via the web service. What you are then interested in doing is creating a client "wrapper" for your web service API. This is what the client would download and use in their application (similar to Facebook.NET). This would be an assembly project and house a bunch of classes and so on. These classes would maintain the state of the program utilizing the API and would take care of all the low level plumbing work interacting with the web services by exposing a verbose object model that is easy enough for the user of your wrapper to get around in.
You could do this for any language that could interact with your web services. Java, Python, etc. I suggest using WCF though as you can use TCP for the .NET library and standard web services for the other languages. This will help you to be more performance oriented where possible.