webservice 开发 axis2 简单部署服务 gSoap 客户端通信

WebService 的服务端  webservice 开发 axis2 简单部署服务  就是用前一章中的服务端

 

wsdl如下:

http://localhost:8080/axis2/services/SimpleService?wsdl

 

下载 gsoap 2.8 版本

 第一步生成头文件:

  wsdl2h   –o hello.h -s  http://localhost:8080/axis2/services/SimpleService?wsdl

     参数说明 -s  不要使用STL代码 

 

 第二步 根据头文件生成stub

 soapcpp2.exe -i -C -x hello.h -IF:\gsoap-2.8\gsoap\import

     参数说明 -i 直接使用C++包装类 -x 不要生成一堆看了就恶心的xml -C 只生成客户端相关代码 -I 指定import路径

 

第三步 VS2008 创建 命令行工程  ws5
 
第四步 编辑工程属性   C/C++ -> 预编译头 ->  创建/使用预编译头    选择 不使用预编译头

第五步 编辑工程属性   链接器->输入->附件依赖项  输入 WSock32.Lib

 

第六步 把刚才gsoap生成的文件 soapH.h   soapC.c   soapStub.h  soapClient.c

           和gsoap文件夹下的       stdsoap2.h  stdsoap2.c    拷贝到当前工程下面

 

 第七步 实现

 

#include "stdafx.h"

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>

#include "soapH.h"
#include "SimpleServiceSoap11Binding.nsmap"


int _tmain(int argc, _TCHAR* argv[])
{
	struct soap *soap = soap_new();
    struct _ns1__getGreetingResponse out;

    soap->mode|=SOAP_C_MBSTRING;
    soap_set_mode(soap,SOAP_C_MBSTRING);
    setlocale(0,"chs");

    struct _ns1__getGreeting resq;
    resq.name="超人";
    if(soap_call___ns1__getGreeting(soap,NULL,NULL,&resq,&out)==SOAP_OK){
        printf("%s\n",out.return_);
    }

	printf("Press enter to continue ...");
	getchar();
	return 0;
}

 

 输出结果:

 

 你好 超人
Press enter to continue ...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值