Use gSOAP to implement multi-client, Single-server WebService

Source: Internet
Author: User
Tags wsdl

This project code uses the Scene: 2 WebService client, 1 WebService (originally has 2 webservice, but Fu Sheng's not by our management development).
FS (Fusheng) WebService client, ZS (zhuo) WebService Client. ZS (zhuo Vision) Webservice.
This webserviceclient project consolidates the FS (Fusheng) WebService client, ZS (zhuo) WebService client into a single Dll. ZS (zhuo Webservice) is an independent process.

The Resetqueryrecordperencoderid interface is now added for Webservice. The following is a procedure for adding a new interface:
WebService End:
1. Manually write Pminfo.h,ns__resetqueryrecordcounterperencoderid to add new, header file full content as Follows:
(note that the "//" in the header file is not a comment, it is an gsoap instruction, Indispensable)
gSOAP NS Service Name:pminfo
gSOAP NS Service Protocol:soap
gSOAP NS Service Style:rpc
gSOAP NS Service encoding:encoded

gSOAP NS Schema Namespace:urn:PMInfo

int Ns__resetqueryrecordcounterperencoderid (int Encoder_id,int *result);
int Ns__getfswebserviceurl (std::string *result);
int ns__getpm2_5 (int Encoder_id,int *result);
int NS__GETPM10 (int Encoder_id,int *result);
int ns__getwindspeed (int Encoder_id,int *result);
int Ns__getnoiseval (int Encoder_id,int *result);

2. Enter the following command at the command line, and the required files will be generated from the server, most notably the pminfo.wsdl File. A file can be used in turn to generate a standard gSOAP header file PMInfo.h (this file can be named in Wsdl2h.exe)

Soapcpp2.exe-s-x-i-l pminfo.h-i./import/

3. Execute wsdl2h.exe-o PMInfo.h pminfo.wsdl generate an automatic version PMInfo.h this will convert the pointer type that originally added the interface manually to a reference type. * = "&
4. Re-execute soapcpp2.exe-s-x-i-l pminfo.h-i./import/generate The automatic version of the reference type gSOAP related Files.
5. Compile the Webservicesvr service-side project, generate WebServiceSvr.exe. The Server-side modification is complete at this Time.

Client Side:
Client DLL because it blends two WebService clients, it is more complex than a single customer. The naming and distinguishing of namespaces is basically to make two sets of client not interfere with each other. Because the original soapH.h soapStub.h soapC.cpp These files if the two client will be covered with each other, only one effective, it needs to be separated by the name Space.
1. First copy the newly generated pminfo.wsdl to the webserviceclient directory, while ensuring that the rich WSDL file ("fswebservice.wsdl") is also in this directory:
2.wsdl2h.exe-o Fs.h-qfs fswebservice.wsdl generates FS.h as a gSOAP file (not included in the project).
3. Wsdl2h.exe-o Zs.h-qzs pminfo.wsdl Generation ZS.h
4. Soapcpp2.exe-c-l-i-x-qzs Zs.h-i./import/generate Client related files Note:-x does not generate XML files, these files are useless for coding, a lot of clutter. -qzs using the Zs namespace
5. Soapcpp2.exe-c-l-i-x-qfs fs.h-i./import/generate Rich Client related files
6. soapcpp2.exe-c-penv env.h generate the environment header File. (there is no this file on a single Client)
7. Compile the client Project. End.


Demo:
Compile Testclientdll for Testing.

This article is from the "software technology" blog, please make sure to keep this source http://danielllf.blog.51cto.com/2442311/1856673

Use gSOAP to implement multi-client, Single-server WebService

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.