欢迎来到天天文库
浏览记录
ID:4158857
大小:712.47 KB
页数:8页
时间:2017-11-29
《c、c++与webservice》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、C/C++与WEBSERVICEStart:2011.03.06Updated:2011.03.08王凡(wangfan)wf141732@sohu.comwoshiwangfan@gmail.comhttp://t.qq.com/lingmengfei版本修改日期内容1.02011.03.08创建1.简介1.1.环境信息Gsoap:2.81.2.相关文档《LinuxCGI》2.软件准备2.1.Gsoap2下载地址:http://downloads.sourceforge.net/project/gsoap2/gSOAP/gsoap_
2、2.8.1.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fgsoap2%2Fdevelop&ts=1299399273&use_mirror=nchc下载后执行标准的配置编译cdgsoap2./configure./make./makeinstall2.2.服务器准备参照《LinuxCGI》3.一个简单的例子做一个获取当前时间的例子3.1.服务端新增文件currentTime.h//File:currentTime.h//gsoapnsservicename:currentTime//
3、gsoapnsservicenamespace:urn:currentTime//gsoapnsservicelocation:http://192.168.115.129:89/ws/currentTime.cgiintns__currentTime(time_t&response);在上面注释的部分都是丌可或缺的,其中双下划线是由于和java通信的标准只能采用Document/literal格式的标准。另外location是到时候传输给服务器的接口部分。在soap2目录/home/wangfan/gsoap2/gsoap/bin/
4、linux386下面拷贝soapcpp2到建立的add.h目录下面,然后编译add文件./soapcpp2currentTime.h编译完成后会在当前目录下面生成很多文件2再来构建服务器代码,即处理逻辑部分//File:currentTime.cpp#include"soapH.h"//includethegenerateddeclarations#include"currentTime.nsmap"//includetheXMLnamespacemappingsintmain(){//createsoapcontextandserv
5、eoneCGI-basedrequest:returnsoapserve(soapnew());}intnscurrentTime(structsoap*soap,timet&response){response=time(0);returnSOAPOK;}然后编译成cgisoapcpp2-ScurrentTime.hc++-ocurrentTime.cgicurrentTime.cppsoapC.cppsoapServer.cppstdsoap2.cpp3.2.Jdeveloper调用使用jdeveloper来生成客户端345调用的
6、代码写在client文件中6packagecurrenttime;importcom.bea.staxb.types.XMLGregorianCalendar;importjava.util.GregorianCalendar;importjavax.xml.ws.WebServiceRef;//!THECHANGESMADETOTHISFILEWILLBEDESTROYEDIFREGENERATED!//ThissourcefileisgeneratedbyOracletools//Contentsmaybesubjecttocha
7、nge//Forreportingproblems,usethefollowing//Version=OracleWebServices(11.1.1.0.0,build101221.1153.15811)publicclassCurrentTimeClient{@WebServiceRefprivatestaticCurrentTime_ServicecurrentTime_Service;publicstaticvoidmain(String[]args){currentTime_Service=newCurrentTime_Se
8、rvice();CurrentTimePortTypecurrentTimePortType=currentTime_Service.getCurrentTime();System.out.println(current
此文档下载收益归作者所有