Introduction
Some days ago I faced the problem of calling the Webservices from VC++ 6.0 written in C#. The I searched on Google and
found the article by Neil Yao that was very useful. Then I started to find the another way for calling the webservices. I came to know about the SPROXY.EXE. It is a command line tool that generates native C++ client code for accessing an XML
Web service based on a WSDL description.
Soap Features:
Soap is a protocol which helps to communicate between the applications. Sending messages through internet. It
is language independent, platform independent and is based on XML. Today the better way to communicate between is via
Http request. Soap was brought in for this purpose.
Creating the Application:
First Step:
Creating Web Service :
Create the virtual directory and in that Create the Asp.net web Service project. Name it as MyWebService . In
Implementation file that is MyWebService.asmx.cs file write the below code after the Component Designer Generated Code heading:
[WebMethod] // Web method which will be exposed by the webservice.
public string MyFun(String strMyName)
{
return "Hello " + strMyName;
}
Now build the WebService.
Second Step:
Using SPROXY.EXE
Go to the Visual studio 2003 command prompt there you type the following line:
sproxy/wsdl Webservice_URL
It will generate one header file which is native code. In this file the namespace name and Class name is same and you can find their signatures there.
Third Step:
Creating MFC Application
I am using Visual Studio 2003. Create New VC++ project then choose MFC Application after that you will see the
MFC Application wizard. Click on Application type and Select dialog based application and Click finish. Now go to Resource
view, place one button on it and name it as Call WebService and name of button as btnWebService. Double Click
on the button you will see the message handler added for the button. You will See the OnbtnWebService() function being added.
Now add the file created in Step Second in the Application. You will find the new class been created there. Now on click of OnbtnWebService() create the object of class and you can invoke the WebServices Methods. For this you have to include the header file and write the one more statement as:
Using namespace createdby_Sproxy;
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here