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代码
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,&resq,&out)==SOAP_OK){ printf("%s\n",out.return_); } printf("Press enter to continue ..."); getchar(); return 0; }
输出结果:
你好 超人Press enter to continue ...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。