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.8gsoapimport ???? 参数说明 -i 直接使用C++包装类 -x 不要生成一堆看了就恶心的xml -C 只生成客户端相关代码 -I 指定import路径 ? 第三步 VS2008 创建 命令行工程? ws5 第五步 编辑工程属性?? 链接器->输入->附件依赖项? 输入 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,&resq,&out)==SOAP_OK){ printf("%sn",out.return_); } printf("Press enter to continue ..."); getchar(); return 0; } ? ?输出结果: ? ?你好 超人Press enter to continue ... (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |