gsoap常规用法:

  1. 通过wsdl文件创建头文件
//通过wsdl文件创建头文件
wsdl2h [options] -o file.h ... WSDL and XSD files or URLs to WSDLs and XSDs ...
  1. 通过头文件创建cpp实现源文件
//通过头文件创建cpp实现源文件
soapcpp2 [options] file.h
  1. 将生成的下列文件拷贝到项目中使用
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文件会被覆盖,或者提前拷贝走,放入一个项目,会存在很多基础方法实现重复定义等问题,需要特殊处理.

  1. 通过多个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
  1. 通过头文件创建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
  1. 创建单个统一的头文件
//通过wsdl文件1,2创建单个统一头文件
wsdl2h.exe -o ServiceAll.h -t typemap.dat service1.wsdl service2.wsdl
  1. 创建单个统一的实现源文件
//通过wsdl文件1,2创建cpp实现源文件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. Leetcode(28)-实现strStr()

    实现 strStr() 函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始).如果不存在,则返 ...

  2. 三、mysql主从复制

    1 MySQL 主从复制 1.1 主从复制的含义 在 MySQL 多服务器的架构中,至少要有一个主节点(master),跟主节点相对的,我们把它叫做从节点(slave). 主从复制,就是把主节点的数据 ...

  3. ES2021 & Pipeline operator (|>) / 管道运算符 |>

    ES2021 & Pipeline operator (|>) / 管道运算符 |> demo "use strict"; /** * * @author xg ...

  4. how to create a ring progress bar in web skills

    how to create a ring progress bar in web skills ring progress bar & circle progress bar canvas j ...

  5. Chrome DevTools & Slow 3G Network

    Chrome DevTools & Slow 3G Network shortcuts https://developers.google.com/web/tools/chrome-devto ...

  6. component & slot

    component & slot <template> <div class="myHeaderContainer"> <header cla ...

  7. react hooks useEffect 取消 promise

    react hooks useEffect 取消 promise cancel promise https://github.com/facebook/react/issues/15006#issue ...

  8. js 生成Excel

    https://www.npmjs.com/package/xlsx 安装依赖 npm install xlsx Example import * as XLSX from "xlsx&qu ...

  9. Redis 博文索引

    博文索引 Redis 对象与编码 Redis 持久化 Redis 主从复制 Redis 哨兵 Redis 缓存淘汰 Redis 集合统计 Redis 简介

  10. Baidu Apollo use: command " rosbag " not fonud

    https://github.com/ApolloAuto/apollo/issues/181 1.If using dev docker env, you need run apollo.sh bu ...