Simple communication between gsoap and ASP. NET

Source: Internet
Author: User
Tags wsdl

Gsoap is a cross-platform implementation of soap communication.Source codeLibrary. This is my incomplete understanding of this open-source project. This is what we can introduce, and there may be errors.

Because I am working on a project with my colleagues, I need to use C ++ to communicate with the WebService published by ASP. NET on the client. So I started to study this library these days. The example was implemented yesterday.ProgramBecause I am familiar with ASP. NET, I can only keep the communication with the WebService published by ASP. NET to this day. In the evening, I checked the simple application of ASP. NET. Even if I encountered some problems, I established an ASP. NET Server. No write rowCodeVS is used to think of the generated code. Because it is only used as an example, it is not intended to change the code.

To implement the communication between ASP. NET WebService and gsoap, websites built by ASP. NET are indispensable. I am also a newbie in ASP. NET, so I use the generated code. I will not introduce how to create a course. If there are people like me, please refer to my previous articleArticleI encountered some problems in accessing the IIS metadatabase and running WebService for the first time.

After the website is created, you must publish the website. For example, you can view the WebService at http: // localhost/soap/service. asmx. In the browser, We can enter http: // localhost/soap/service. asmx? To obtain the WSDL file. Save the WSDL file with the WSDL extension name.

To gsoap official website /~ Download the latest gsoap version from Engelen/soap.html. You can upload wsdl2h.exeand soapcpp.exe tools in the binfolder.

Wsdl2h.exe can generate a. h file based on a wsdl file. Assume that the name of the WSDL we saved is WebService. WSDL. Enter wsdl2h.exe service. WSDL in the command line. In this way, the corresponding. h file is generated. Then soapcpp.exe generates the corresponding code file based on this. h file. Soapcpp.exe-I WebService. h. nsmap, soapc. CPP, soaph. h, soapservicesoapproxy. h, soapservicesoapproxy. CPP, soapstub. h. These files are required to build the gsoap client. I do not know what other files are used for. If you have any knowledge, I hope you can give me some advice. In addition to these files, we also need to find two files: stdsoap2.h and stdsoap2.cpp. After finding all the files, we need to add these files to the project.

Finally, we need to write a client program. Its function is to obtain the "Hello word" string on the server. Its simple code is as follows:

# Include " Stdafx. h "

# Include"Soapservicesoapproxy. h"
# Include"Servicesoap. nsmap"

Const CharServer []= "Http: // localhost/soap/service. asmx";

IntMain (IntArgc,Char **Argv)
Printf ("Getting Hello World words! \ N");

Servicesoapproxy soapservice;
Soapservice. soap_endpoint=Server;

_ NS1 _ helloworld input;
_ NS1 _ helloworldresponse output;

Soapservice. helloworld (&Input,&Output );

Printf ("% S", Output. helloworldresult->C_str ());

Return 0;


Then we run the code and the following characters will appear:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.