cxf实现webservice

cxf实现webservice

ID:26556516

大小:50.50 KB

页数:6页

时间:2018-11-27

cxf实现webservice_第1页
cxf实现webservice_第2页
cxf实现webservice_第3页
cxf实现webservice_第4页
cxf实现webservice_第5页
cxf实现webservice_第6页
资源描述:

《cxf实现webservice》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、使用Spring+CXF开发WebServiceApacheCXF提供方便的Spring整合方法,可以通过注解、Spring标签式配置来暴露WebServices和消费WebServices各种类型的Annotation。@WebService和@WebMethod是WSDL映射Annatotion。这些Annotation将描述WebService的WSDL文档元素和Java源代码联系在一起。@SOAPBinding是一个绑定的annotation用来说明网络协议和格式。1、@WebServicean

2、notation的元素name,serviceName和targetNamespace成员用来描述wsdl:portType,wsdl:service,和targetNameSpace生成WebService中的WSDL文件。2、@SOAPBinding是一个用来描述SOAP格式和RPC的协议的绑定Annotation。3、@WebMethodAnnotation的operationName成员描述了wsdl:operation,而且它的操作描述了WSDL文档中的SOAPAction头部。这是客户端必须

3、要放入到SQAPHeader中的数值,SOAP1.1中的一种约束。4、@WebParamAnnotation的partName成员描述了WSDL文档中的wsdl:part。5、@WebResultAnnotation的partName成员描述了wsdl:part用来返回WSDL文档的值。例如下面使用annotation定义了一个webservice:importjava.util.List;importjavax.jws.WebMethod;importjavax.jws.WebParam;import

4、javax.jws.WebResult;importjavax.jws.WebService;importcom.cxf.pojo.User;@WebService(targetNamespace="http://jdk.study.hermit.org/client")publicinterfaceUserService{@WebMethod(operationName="Insert")publicvoidinsert(@WebParam(name="userId")Stringuserid,@We

5、bParam(name="userName")Stringusername,@WebParam(name="userEmail")Stringuseremail,@WebParam(name="userAge")intuserage);@WebMethod(operationName="GetUserById")@WebResult(name="result")publicUsergetUserById(@WebParam(name="userid")Stringuserid);@WebMethod(o

6、perationName="GetAllUsers")@WebResult(name="result")publicListgetAllUsers();}其实现类如下所示:importjava.util.List;importjavax.jws.WebService;importcom.cxf.dao.UserDao;importcom.cxf.pojo.User;importcom.cxf.service.UserService;@WebService(endpointInterface="com.c

7、xf.service.UserService")publicclassUserServiceImplimplementsUserService{privateUserDaouserDao;publicListgetAllUsers(){returnuserDao.findAllUser();}publicUsergetUserById(Stringuserid){returnuserDao.findUserById(userid);}publicvoidinsert(Stringuserid,Strin

8、gusername,Stringuseremail,intuserage){Useruser=newUser();user.setUserage(userage);user.setUseremail(useremail);user.setUserid(userid);user.setUsername(username);userDao.insert(user);System.out.println("insertsuccessfully!"

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。