gsoap常规用法:

  1. 通过wsdl文件创建头文件
  1. //通过wsdl文件创建头文件
  2. wsdl2h [options] -o file.h ... WSDL and XSD files or URLs to WSDLs and XSDs ...
  1. 通过头文件创建cpp实现源文件
  1. //通过头文件创建cpp实现源文件
  2. soapcpp2 [options] file.h
  1. 将生成的下列文件拷贝到项目中使用
  1. soapClient.c[pp] client-side stub functions
  2. soapServer.c[pp] server-side dispatch functions
  3. soapC.c[pp] XML serializers for all XML SOAP API function arguments
  4. soapH.h XML serializers and service API functions
  5. soapStub.h cleaned-up copy of the file.h declarations, this file is included by soapH.h
  6. prefix.nsmap XML namespace bindings table to #include in your code

4.不过一般情况通过soapcpp2参数-j控制创建c++更强大的代理类和服务类

  1. soapNameProxy.h
  2. soapNameProxy.cpp
  3. soapNameService.h
  4. soapNameService.cpp

5.拷贝文件到项目使用

6.服务端用法

  1. #include "soapName.nsmap" // XML namespace mapping table (only needed once at the global level)
  2. #include "soapNameService.h" // the service class, also #includes "soapH.h" and "soapStub.h"
  3. int main()
  4. {
  5. soapNameService srv(SOAP_XML_INDENT);
  6. if (srv.serve() != SOAP_OK)
  7. srv.soap_stream_fault(std::cerr);
  8. srv.destroy(); // same as: soap_destroy(srv.soap); soap_end(srv.soap);
  9. }
  10. int srv::add(double a, double b, double &result)
  11. {
  12. result = a + b;
  13. return SOAP_OK;
  14. }

6.客户端用法

  1. #include "soapName.nsmap" // XML namespace mapping table (only needed once at the global level)
  2. #include "soapNameProxy.h" // the proxy class, also #includes "soapH.h" and "soapStub.h"
  3. int main()
  4. {
  5. soapNameProxy cli;
  6. double sum;
  7. if (cli.add(1.23, 4.56, sum) == SOAP_OK)
  8. std::cout << "Sum = " << sum << std::endl;
  9. else
  10. cli.soap_stream_fault(std::cerr);
  11. cli.destroy(); // same as: soap_destroy(cli.soap); soap_end(cli.soap);
  12. }

多wsdl集成

但是很多时候,一个项目中可能即要做服务端,又要连接其他服务,做客户端,或者同时需要连接多个服务端,调用接口,又或者多个服务端,如果仅仅使用常规方法,多调用几次,soapC.c[pp],soapH.h,soapStub.h,prefix.nsmap文件会被覆盖,或者提前拷贝走,放入一个项目,会存在很多基础方法实现重复定义等问题,需要特殊处理.

  1. 通过多个wsdl文件创建多个头文件
  1. //通过wsdl文件创建头文件1
  2. wsdl2h.exe -o Service1.h -t typemap.dat service1.wsdl
  3. //通过wsdl文件创建头文件2
  4. wsdl2h.exe -o Service2.h -t typemap.dat service2.wsdl
  1. 通过头文件创建cpp实现源文件
  1. //通过头文件创建cpp实现源文件1
  2. soapcpp2.exe -C -L -j -x -I import Service1.h
  3. //通过头文件创建cpp实现源文件2
  4. soapcpp2.exe -C -L -j -x -I import Service2.h
  1. 创建单个统一的头文件
  1. //通过wsdl文件1,2创建单个统一头文件
  2. wsdl2h.exe -o ServiceAll.h -t typemap.dat service1.wsdl service2.wsdl
  1. 创建单个统一的实现源文件
  1. //通过wsdl文件1,2创建cpp实现源文件2
  2. soapcpp2.exe -C -L -j -x -I import ServiceAll.h

5.删掉多余的重复.nsmap文件,留一个就可以了

6.拷贝到项目中使用即可,同单wsdl模式.

gsoap多wsdl集成的更多相关文章

  1. CPP-网络/通信:gsoap 的教程和使用

    1.1.1     gSOAP 1.1.1 .1      简介 gSOAP 编译工具提供了一个 SOAP/XML 关于 C/C++ 语言的实现,从而让 C/C++ 语言研发 web 服务或客户端程式 ...

  2. gsoap开发webservice

    gSOAP编译工具提供了一个SOAP/XML 关于C/C++ 语言的实现,从而让C/C++语言开发web服务或客户端程序的工作变得轻松了很多.绝大多数的C++web服务工具包提供一组API函数类库来处 ...

  3. C++客户端通过gSOAP调用WebService

    webService三要素: SOAP(Simple Object Access Protocol).WSDL(WebServicesDescriptionLanguage).UDDI(Univers ...

  4. gsoap

    C++中如何使用gsoap开发WebService 1. 什么是gSOAPgSOAP是一个夸平台的,用于开发Web Service服务端和客户端的工具,在Windows.Linux.MAC OS和UN ...

  5. C++客户端访问WebService VS2008

    VS2008及之后的版本已经不支持使用C++开发WEBService服务了,如果要在VS上开发WEBService,需要使用C#开发语言. 一.gSOAP简介 gSOAP编译工具提供了一个基于SOAP ...

  6. 使用WCF实现SOA面向服务编程—— 架构设计

    原文地址:http://www.cnblogs.com/leslies2/archive/2011/03/29/1997889.html SOA本身就是一种面向企业级服务的系统架构,简单来说,SOA就 ...

  7. JAVA记录-WebService开发部署

    JWS.Axis2.cxf 1.下载axis2.war和axis2.bin.zip 2.将axis2.war包部署到Tomcat下,启动Tomcat测试:http://localhost:8089/a ...

  8. [Teamcenter 2007 开发实战] 调用web service

    前言 在TC的服务端开发中, 能够使用gsoap 来调用web service. 怎样使用 gsoap  , 參考 gsoap 实现 C/C++ 调用web service 接下来介绍怎样在TC中进行 ...

  9. onvif开发总结

    ONVIF开发经验总结 ONVIF开发经验总结............................................................................. ...

随机推荐

  1. Gym 101170I Iron and Coal(BFS + 思维)题解

    题意:有一个有向图,有些点是煤,有些点是铁,但不会同时有铁和煤.现在我要从1出发,占领可以到达的点.问最少占领几个点能同时拥有一个煤和一个铁(1不用占领). 思路:思路很秀啊.我们从1往外bfs,得到 ...

  2. springboot使用RestTemplate+httpclient连接池发送http消息

    简介 RestTemplate是spring支持的一个请求http rest服务的模板对象,性质上有点像jdbcTemplate RestTemplate底层还是使用的httpclient(org.a ...

  3. js中当for循环中有事件要使用循环变量时,变量用var声明和let声明的区别

    var 声明一个全局变量,声明的变量会变量提升: let 声明一个局部变量: 当页面加载完后,for循环也结束了,如果用var声明的变量此时也随着for循环的结束而自增到满足结束循环的条件, 此时调用 ...

  4. Github Docs All In One

    Github Docs All In One docs https://docs.github.com/en https://github.com/github/docs GitHub REST AP ...

  5. Navigator.registerProtocolHandler All In One

    Navigator.registerProtocolHandler All In One Web API custom protocol URL Schemes URL Protocols https ...

  6. how to read the system information by using the node cli tool?

    how to read the system information by using the node cli tool? node cli & get system info demos ...

  7. js uppercase the first letter of string

    js uppercase the first letter of string js String.toUpperCase `-webkit-border-image`.split(`-`).filt ...

  8. macOS 显示/隐藏 AirPlay

    macOS 显示/隐藏 AirPlay AirPlay Sidecar 必须用相同的 Apple ID 登录 mac 和 ipad, 才能使用! https://www.apple.com/macos ...

  9. element ui 停止维护了

    ️‍♂️ element ui 停止维护了 最近看到有人说 element ui 已经停止维护了,还有点不相信; 不过到 github 验证一下,好像是真的呀 4 个月,没有任何更新了 https:/ ...

  10. Spring学习过程中遇到的No bean named 'beanId' is defined报错

    ApplicationContext applicationContext= new ClassPathXmlApplicationContext("bean.xml");Obje ...