Gsoap Development Guide in Visual Studio

Source: Internet
Author: User
  • Preface

Generally, you can use the soap Toolkit 3.0 SDK provided by Microsoft to write a WebService client in VC. This is convenient and quick, but as you may know, such code deployment is very problematic, you must deploy the machine to install the SDK.

Gsoap is an open-source project that can solve this deployment problem. However, since it is only an open-source project, seamless integration with VC is not an easy task.

Http://www.cs.fsu.edu /~ Engelen/soapdoc2.html is the gsoap guide. It will not be successful if you follow this guide step by step.

  • Test Environment

IDE version:

Vs2008 (applicable to other versions)

Gsoap version:

Gsoap2.7.12 (applicable to other versions)

  • Wizard

1. Environment assumptions:

1) there is a WebService: http: // localhost: 16041/webservice1.asmx, which exposes the Method

[Webmethod]
Public String helloworld ()
{
Return "Hello World ";
}

2) assume that the Win32 console project CLN is generated using the wizard, and the directory c:/code/CLN

3) assume that the gsoap source directory c:/gsoap

2. preparation:

1) create a subdirectory C:/code/CLN/gsoap

2) Copy wsdl2h.exe,soapcpp2.exe to C:/code/CLN/gsoap. The 2 file can be found in C:/gsoap/bin/Win32.

3) Copy stdsoap2.h, stdsoap2.cpp to C:/code/CLN/gsoap. The 2 files are in the C:/gsoap root directory.

3. wsdl2h.. h

Run the command line to enter C:/code/CLN/gsoap.

Wsdl2h-I "C:/gsoap/WS"-O test. h http: // localhost: 16041/webservice1.asmx? WSDL

This operation will generate C:/code/CLN/gsoap/test. h

4. soapcpp2 compilation. cpp

Soapcpp2-I "C:/gsoap/import" test. h

5. Integrated CLN project Compilation

Add soapc. cpp, soapclient. cpp, and stdsoap2.cpp to the project, right-click the three CPP files, and remove the pre-compilation header. Otherwise, the project cannot be compiled normally.

CLN. cpp source code

# Include "stdafx. H"
# Include "gsoap/soapwebservice1soapproxy. H"
# Include "gsoap/webservice1soap. nsmap"

Int _ tmain (INT argc, _ tchar * argv [])
{
Webservice1soap S;
_ NS1 _ helloworld request;
_ NS1 _ helloworldresponse response;
S. _ ns__ helloworld (& request, & response );

Return 0;
}

 

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: info-contact@alibabacloud.com 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.