加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

使用gsoap实现多客户端,单服务端webservice

发布时间:2020-12-16 22:01:57 所属栏目:安全 来源:网络整理
导读:本工程代码使用场景:2个webservice client ,1个webservice(本来有2个webservice,但富盛的不由我们管理开发)。FS(富盛) webservice client,ZS(卓视) webservice client.? ZS(卓视) webservice.本WebServiceClient 工程将FS(富盛) webservice client,

本工程代码使用场景:2个webservice client ,1个webservice(本来有2个webservice,但富盛的不由我们管理开发)。FS(富盛) webservice client,ZS(卓视) webservice client.? ZS(卓视) webservice.本WebServiceClient 工程将FS(富盛) webservice client,ZS(卓视) webservice client合并到一个dll中。ZS(卓视) webservice为一个独立进程。现为webservice添加 ResetQueryRecordPerEncoderId 接口。以下是添加新接口过程:webservice 端:1.手动编写pminfo.h,ns__ResetQueryRecordCounterPerEncoderId为新添加,头文件全内容如下:(注意头文件里“//”不是注释,是gsoap指令,不可缺少)//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:PMInfoint 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.在命令行中输入以下命令,回车,则会生成服务端所需文件,最主要的是产生了 PMInfo.wsdl 文件。以文件可以反过来用wsdl2h.exe来生成标准的 gsoap头文件PMInfo.h(此文件可另外命名)soapcpp2.exe -S -x -i -L PMInfo.h -I./import/3.执行 wsdl2h.exe -o PMInfo.h? PMInfo.wsdl 生成 自动版 PMInfo.h 这里面会将原来手动添加接口的指针类型转换为引用类型。* =》 &4.再执行 soapcpp2.exe -S -x -i -L PMInfo.h -I./import/ 生成自动版的引用类型gsoap相关文件。5.编译WebServiceSvr 服务端工程,会生成WebServiceSvr.exe.此时服务端修改完成.Client 端:客户端DLL因为糅合了两个webservice client,故相对单一client 要复杂一些。主要是命名空间的命名和区分,其实就是为了让两套client 互相不干扰。因为原本soapH.h soapStub.h soapC.cpp 这些文件如果在两个client下会相互覆盖,只有一个生效,故需用命名空间分开。1.首先将刚生成的PMInfo.wsdl拷贝到 WebServiceClient 目录 下,同时确保富盛的wsdl文件(“FSWebService.wsdl”)也在此目录下:2.wsdl2h.exe -o FS.h -qFS FSWebService.wsdl 生成FS.h作为gsoap文件(工程中不必包含).3. wsdl2h.exe -o ZS.h -qZS PMInfo.wsdl 生成ZS.h 4. soapcpp2.exe -C -L -i -x -qZS ZS.h -I./import/ 生成卓视客户端相关文件? 注意:-x 不生成xml文件,这些文件对编码没用,一大堆,显得杂乱。-qZS 使用ZS命名空间5. soapcpp2.exe -C -L -i -x -qFS FS.h -I./import/ 生成富盛客户端相关文件6. soapcpp2.exe -C -penv env.h?? 生成环境头文件。(单客户端 时没有此文件)7. 编译客户端工程。结束。Demo:编译testClientDLL进行测试。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读