gsoap使用示例

  1. download gsoap_2.8.33.zip https://sourceforge.net/projects/gsoap2/files/gSOAP/
    Looking for the latest version? Download gSOAP 2.8.33 stable (24.1 MB)
  2. unzip gsoap_2.8.33.zip // 解压gsoap_2.8.33.zip
  3. cd gsoap-2.8
  4. 编译生成 soapcpp2和wsdl2h这2个工具。
    打开 INSTALL.sh
    本机编译(参考35~44行):
    To do so, use the command line to run ‘make’ with generic makefiles:

         $ cd gsoap/src
         $ make -f MakefileManual
         $ cd gsoap/wsdl
         $ make -f MakefileManual
    
     This builds 'soapcpp' with 'gcc' and 'wsdl2h' with 'g++' and installs the
     binaries in gsoap/bin. Move them to a bin directory or include them in your
     executalbe path.
    

    交叉编译(参考51~56行):
    To compile with a different compiler instead of GCC, for example ‘clang’, use:

         $ cd gsoap/src
         $ make CC=clang -f MakefileManual
         $ cd gsoap/wsdl
         $ make CC=clang CPP=clang++ -f MakefileManual secure
     注:secure选项为HTTPS使能。 不需要HTTPS时不需要 secure 选项。
    
  5. 将gsoap/bin目录下的 soapcpp2和wsdl2h拷贝到$PATH目录下。
  6. 测试gsoap.(主机可以访问互联网)

       $ cd gsoap/samples/calc
       $ cp ../../stdsoap2.c .
       $ cp ../../stdsoap2.h .
       $ soapcpp2 -c calc.h
       $ cc -o calcclient calcclient.c stdsoap2.c soapC.c soapClient.c
    

    编译生成calcclient, 并执行
    $ ./calcclient add 3 4
    result = 7
    测试成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
带gsoap-2.8源码,基于服务器客户端的实例,带自动生成服务客户端代码的批处理程序,及如何使用。带自己学习参考的教程; 0.解压附件,soapInterface.bat所在路径不得含中文 空格 1.新建头文件 取soapInterface.bat文件的同名:soapInterface.h 文件内编写接口,具体说明看附件参考的教程 //gsoap ns service name: gservice //gsoap ns service style: rpc int ns__add(int num1, int num2, int* result ); int ns__sub(int num1, int num2, int* result ); int ns__mult( int num1, int num2, int *result); int ns__divid( int num1, int num2, int *result); 2.从附件内gsoap-2.8包中搜索复制stdsoap2.h,stdsoap2.cpp,soapcpp2.exe, 存放于soapInterface.bat同级目录 3.双击soapInterface.bat运行。生成gClientSoap,gServerSoap两个文件夹,分别复制到服务器工程与客户端工程中使用 4.gClientSoap,gServerSoap两个文件夹内用到的文件功能说明,更多参考附件教程 1)soapC.cpp , soapH.h//soap的序列和反序列代码,它已经包含了soapStub.h 2)soapServer.c ppsoapServerLib.cpp //服务器端代码(纯C代码是soapServer.c soapServerLib.c ),soapServerLib.cpp文件则只是简单地包含soapServer.cpp和soapC.cpp 3)soapClient.cpp soapClientLib.cpp//客户端代码(纯C代码是soapClient.csoapClientLib.c ),soapClientLib.cpp文件则只是简单地包含soapClient.cpp和soapC.cpp 4) soapStub.h // soap的存根文件,定义了我们编写的头文件里对应的远程调用模型 5) add.nsmap //XML服务命名空间 6)服务器端要载入的文件有:soapServer.cpp,soapC.cpp,stdsoap2.cpp; 要包含的文件有:gservice.nsmap,soapH.h; 客户端要输入的文件有: soapClient.cpp,soapC.cpp,stdsoap2.cpp; 要包含的文件有:gservice.nsmap,soapH.h

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值