![]() |
Web Development »
Web Services »
General
Intermediate
Calling WebServices Using SPROXY in VC++By Ganesh_TCalling WebServices methods using sproxy.exe provided by Visual Studio 2003 |
C#, VC7, Windows, .NET, Visual Studio, MFC, ATL, Dev
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
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 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.
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;
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 14 Jun 2006 Editor: |
Copyright 2006 by Ganesh_T Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |