Background requirements.
1, there is a WebService server side. The concrete manifestation is a link--http:\\xxxxxxxxxxxxxxxxxxx.com?wsdl
2, download one of the most gSOAP package, (go to the official website to download). Unzip the directory for D:\workspace\2, lis\gsoap-2.8.
Operation Process.
1, in the Bin\win32 directory to build an empty header file WebService.h (as if you can not do);
2, then establish a character conversion rule file Wsmap.dat, the file content is xsd__string = | std::wstring | Wchar_t* (in order to support Chinese in some way);
3. Start cmd, go to \bin\win32 directory, call Wsdl2h.exe to generate header file interface definition, command: (Generate. h file)
Wsdl2h-o webservice.h-n ws-t Wsmap.dat Http://XXXXXXXXXXXXXXXXXXXXXX.asmx?WSDL
After this step is complete, the WebService.h file contains the content.
The operation commands for WSDL2H are as follows:
- - o file name, specifying output header file
- The- n namespace prefix replaces the default NS
- -C generates a pure code, otherwise C + + code
- - s do not use STL code
- - t file name, specifying type map file, default = Typemap.dat
- - e prohibit namespace prefixes for enum members
4, in the command line input soapcpp2-j WebService.h (parse WebService.h, generate stub program);
The resulting file then contains the server and the client. Do not add servers to the client.
The list of source files for the entire project is as follows:
Main.cpp (player manually generated)
SoapC.cpp (generated in this step)
SoapH.h (generated in this step)
SoapLimsInfoServiceImplServiceSoapBindingProxy.cpp (generated in this step)
SoapLimsInfoServiceImplServiceSoapBindingProxy.h (generated in this step)
SoapStub.h (generated in this step)
Stdsoap2.cpp (available under gSOAP folder)
Stdsoap2.h (available under gSOAP folder)
5, the new project. Additional file list into step 4.
Add # include "Weatherwssoap.nsmap" to the header file of the project, or there will be an issue with namespace compilation errors.
6. My main code
1#include"SoapLimsInfoServiceImplServiceSoapBindingProxy.h"2 3#include"Limsinfoserviceimplservicesoapbinding.nsmap"4 5 using namespacestd;6 7 intMain ()8 {9 Limsinfoserviceimplservicesoapbindingproxy WebService;Ten OneWs1__getpatientinformation barcode =ws1__getpatientinformation (); A -Ws1__getpatientinformationresponse pantientres =ws1__getpatientinformationresponse (); - the stringTMP ="157961253"; -Barcode. Ws1__barcode = &tmp; - - intresult = Webservice.getpatientinformation (&barcode, pantientres); + - if(SOAP_OK = =result) + { Acout << *pantientres. out; at } - -Cin.Get(); - return 0; -}
gSOAP, C + +. WebService's client.