gsoap多wsdl集成
gsoap常规用法:
- 通过wsdl文件创建头文件
//通过wsdl文件创建头文件
wsdl2h [options] -o file.h ... WSDL and XSD files or URLs to WSDLs and XSDs ...
- 通过头文件创建cpp实现源文件
//通过头文件创建cpp实现源文件
soapcpp2 [options] file.h
- 将生成的下列文件拷贝到项目中使用
soapClient.c[pp] client-side stub functions
soapServer.c[pp] server-side dispatch functions
soapC.c[pp] XML serializers for all XML SOAP API function arguments
soapH.h XML serializers and service API functions
soapStub.h cleaned-up copy of the file.h declarations, this file is included by soapH.h
prefix.nsmap XML namespace bindings table to #include in your code
4.不过一般情况通过soapcpp2参数-j控制创建c++更强大的代理类和服务类
soapNameProxy.h
soapNameProxy.cpp
soapNameService.h
soapNameService.cpp
5.拷贝文件到项目使用
6.服务端用法
#include "soapName.nsmap" // XML namespace mapping table (only needed once at the global level)
#include "soapNameService.h" // the service class, also #includes "soapH.h" and "soapStub.h"
int main()
{
soapNameService srv(SOAP_XML_INDENT);
if (srv.serve() != SOAP_OK)
srv.soap_stream_fault(std::cerr);
srv.destroy(); // same as: soap_destroy(srv.soap); soap_end(srv.soap);
}
int srv::add(double a, double b, double &result)
{
result = a + b;
return SOAP_OK;
}
6.客户端用法
#include "soapName.nsmap" // XML namespace mapping table (only needed once at the global level)
#include "soapNameProxy.h" // the proxy class, also #includes "soapH.h" and "soapStub.h"
int main()
{
soapNameProxy cli;
double sum;
if (cli.add(1.23, 4.56, sum) == SOAP_OK)
std::cout << "Sum = " << sum << std::endl;
else
cli.soap_stream_fault(std::cerr);
cli.destroy(); // same as: soap_destroy(cli.soap); soap_end(cli.soap);
}
多wsdl集成
但是很多时候,一个项目中可能即要做服务端,又要连接其他服务,做客户端,或者同时需要连接多个服务端,调用接口,又或者多个服务端,如果仅仅使用常规方法,多调用几次,soapC.c[pp],soapH.h,soapStub.h,prefix.nsmap文件会被覆盖,或者提前拷贝走,放入一个项目,会存在很多基础方法实现重复定义等问题,需要特殊处理.
- 通过多个wsdl文件创建多个头文件
//通过wsdl文件创建头文件1
wsdl2h.exe -o Service1.h -t typemap.dat service1.wsdl
//通过wsdl文件创建头文件2
wsdl2h.exe -o Service2.h -t typemap.dat service2.wsdl
- 通过头文件创建cpp实现源文件
//通过头文件创建cpp实现源文件1
soapcpp2.exe -C -L -j -x -I import Service1.h
//通过头文件创建cpp实现源文件2
soapcpp2.exe -C -L -j -x -I import Service2.h
- 创建单个统一的头文件
//通过wsdl文件1,2创建单个统一头文件
wsdl2h.exe -o ServiceAll.h -t typemap.dat service1.wsdl service2.wsdl
- 创建单个统一的实现源文件
//通过wsdl文件1,2创建cpp实现源文件2
soapcpp2.exe -C -L -j -x -I import ServiceAll.h
5.删掉多余的重复.nsmap文件,留一个就可以了
6.拷贝到项目中使用即可,同单wsdl模式.
gsoap多wsdl集成的更多相关文章
- CPP-网络/通信:gsoap 的教程和使用
1.1.1 gSOAP 1.1.1 .1 简介 gSOAP 编译工具提供了一个 SOAP/XML 关于 C/C++ 语言的实现,从而让 C/C++ 语言研发 web 服务或客户端程式 ...
- gsoap开发webservice
gSOAP编译工具提供了一个SOAP/XML 关于C/C++ 语言的实现,从而让C/C++语言开发web服务或客户端程序的工作变得轻松了很多.绝大多数的C++web服务工具包提供一组API函数类库来处 ...
- C++客户端通过gSOAP调用WebService
webService三要素: SOAP(Simple Object Access Protocol).WSDL(WebServicesDescriptionLanguage).UDDI(Univers ...
- gsoap
C++中如何使用gsoap开发WebService 1. 什么是gSOAPgSOAP是一个夸平台的,用于开发Web Service服务端和客户端的工具,在Windows.Linux.MAC OS和UN ...
- C++客户端访问WebService VS2008
VS2008及之后的版本已经不支持使用C++开发WEBService服务了,如果要在VS上开发WEBService,需要使用C#开发语言. 一.gSOAP简介 gSOAP编译工具提供了一个基于SOAP ...
- 使用WCF实现SOA面向服务编程—— 架构设计
原文地址:http://www.cnblogs.com/leslies2/archive/2011/03/29/1997889.html SOA本身就是一种面向企业级服务的系统架构,简单来说,SOA就 ...
- JAVA记录-WebService开发部署
JWS.Axis2.cxf 1.下载axis2.war和axis2.bin.zip 2.将axis2.war包部署到Tomcat下,启动Tomcat测试:http://localhost:8089/a ...
- [Teamcenter 2007 开发实战] 调用web service
前言 在TC的服务端开发中, 能够使用gsoap 来调用web service. 怎样使用 gsoap , 參考 gsoap 实现 C/C++ 调用web service 接下来介绍怎样在TC中进行 ...
- onvif开发总结
ONVIF开发经验总结 ONVIF开发经验总结............................................................................. ...
随机推荐
- Gym 101170I Iron and Coal(BFS + 思维)题解
题意:有一个有向图,有些点是煤,有些点是铁,但不会同时有铁和煤.现在我要从1出发,占领可以到达的点.问最少占领几个点能同时拥有一个煤和一个铁(1不用占领). 思路:思路很秀啊.我们从1往外bfs,得到 ...
- springboot使用RestTemplate+httpclient连接池发送http消息
简介 RestTemplate是spring支持的一个请求http rest服务的模板对象,性质上有点像jdbcTemplate RestTemplate底层还是使用的httpclient(org.a ...
- js中当for循环中有事件要使用循环变量时,变量用var声明和let声明的区别
var 声明一个全局变量,声明的变量会变量提升: let 声明一个局部变量: 当页面加载完后,for循环也结束了,如果用var声明的变量此时也随着for循环的结束而自增到满足结束循环的条件, 此时调用 ...
- Github Docs All In One
Github Docs All In One docs https://docs.github.com/en https://github.com/github/docs GitHub REST AP ...
- Navigator.registerProtocolHandler All In One
Navigator.registerProtocolHandler All In One Web API custom protocol URL Schemes URL Protocols https ...
- 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 ...
- js uppercase the first letter of string
js uppercase the first letter of string js String.toUpperCase `-webkit-border-image`.split(`-`).filt ...
- macOS 显示/隐藏 AirPlay
macOS 显示/隐藏 AirPlay AirPlay Sidecar 必须用相同的 Apple ID 登录 mac 和 ipad, 才能使用! https://www.apple.com/macos ...
- element ui 停止维护了
️♂️ element ui 停止维护了 最近看到有人说 element ui 已经停止维护了,还有点不相信; 不过到 github 验证一下,好像是真的呀 4 个月,没有任何更新了 https:/ ...
- Spring学习过程中遇到的No bean named 'beanId' is defined报错
ApplicationContext applicationContext= new ClassPathXmlApplicationContext("bean.xml");Obje ...