ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:52.46KB ,
资源ID:10214317      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-10214317.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(CXF配置和开发流程.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

CXF配置和开发流程.docx

1、CXF配置和开发流程CXF的配置和开发流程第一种方式配置信息如下1、 cxf用的jar包http:/cxf.apache.org/download.html可以下载到。2、 web.xml CXFServlet CXF Servlet org.apache.cxf.transport.servlet.CXFServlet 1 CXFServlet /services/* 3、配置文件applicationContext-service.xml(注意红色部分为配置文件新加配置) 配置文件applicationContext-client.xml 注意applicationContext-serv

2、ice.xml配置文件中使用的是标签4、服务类HelloService.javaWebServicepublic interface HelloService public TestResponse hello(WebParam(name=name)String name); 实现类HelloServiceImpl.javaTestResponse.java、TestList.java5、客户端类HelloClient.java6、拦截器MyInterceptor.java各部分代码如下Web.xml!DOCTYPE web-app PUBLIC -/Sun Microsystems, Inc

3、./DTD Web Application 2.3/EN contextConfigLocation WEB-INF/classes/applicationContext.xml org.springframework.web.context.ContextLoaderListener CXFServlet CXF Servlet org.apache.cxf.transport.servlet.CXFServlet 1 CXFServlet /services/* xsd text/xml applicationContext-service.xml applicationContext-c

4、lient.xml HelloService.javapackage com.fxb.webservice.service;import javax.jws.WebParam;import javax.jws.WebService;import javax.jws.soap.SOAPBinding;import javax.jws.soap.SOAPBinding.Style;import com.fxb.webservice.bean.TestResponse;WebServicepublic interface HelloService public TestResponse hello(

5、WebParam(name=name)String name);HelloServiceImpl.javapackage com.fxb.webservice.service.impl;import com.fxb.webservice.bean.TestList;import com.fxb.webservice.bean.TestResponse;import com.fxb.webservice.service.HelloService;public class HelloServiceImpl implements HelloService public TestResponse he

6、llo(String name) System.out.println(name); TestResponse testResponse = new TestResponse(); TestList testList = new TestList(); testList.setName(HelloServiceImpl); testResponse.setTestList(testList); return testResponse; TestResponse.java类package com.fxb.webservice.bean;import javax.xml.bind.annotati

7、on.XmlAccessType;import javax.xml.bind.annotation.XmlAccessorType;import javax.xml.bind.annotation.XmlRootElement;XmlRootElement(name = TestResponse)/设置一级子节点XmlAccessorType(XmlAccessType.FIELD)public class TestResponse protected TestList testList; public TestList getTestList() return testList; publi

8、c void setTestList(TestList testList) this.testList = testList; TestList.java类package com.fxb.webservice.bean;import javax.xml.bind.annotation.XmlAccessType;import javax.xml.bind.annotation.XmlAccessorType;import javax.xml.bind.annotation.XmlRootElement;XmlRootElement(name = TestList)/设置二级子节点XmlAcce

9、ssorType(XmlAccessType.FIELD)public class TestList /类的属性为三级子节点 protected String name; protected String age; public String getName() return name; public void setName(String name) this.name = name; public String getAge() return age; public void setAge(String age) this.age = age; MyInterceptor.javapack

10、age com.fxb.webservice.interceptor;import org.apache.cxf.interceptor.Fault;import org.apache.cxf.message.Message;import org.apache.cxf.phase.AbstractPhaseInterceptor;import org.apache.cxf.phase.Phase;import org.apache.log4j.Logger;public class MyInterceptor extends AbstractPhaseInterceptor private L

11、ogger log = Logger.getLogger(MyInterceptor.class); public MyInterceptor(String phase) super(phase); public MyInterceptor() super(Phase.RECEIVE); SuppressWarnings(static-access) public void handleMessage(Message msg) throws Fault String uri = String.valueOf(msg.get(msg.REQUEST_URI); StringBuffer bf =

12、 new StringBuffer(uri + .xml); msg.put(msg.REQUEST_URI, String.valueOf(bf); System.out.println(in my intercetptor11111111111111111111); System.out.println(msg.get(msg.REQUEST_URI); log.info(in my interceptor:); Override public void handleFault(Message message) super.handleFault(message); System.out.

13、println(handleFault2); HelloClient.javapackage com.fxb.webservice.client;import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.fxb.webservice.bean.TestResponse;import com.fxb.webservice.service.HelloService;public class

14、 HelloClient public static void main(String args) ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String com/fxb/webservice/client/applicationContext-client.xml); HelloService client = (HelloService)context.getBean(client); TestResponse response = client.hello(Joe);Sy

15、stem.out.println(Response: + response.getTestList().getName(); System.exit(0); 通过客户端测试输出为Response: HelloServiceImpl通过http:/localhost:8080/CXFSpring/services/HelloWorldTwo/hello输出为第二种方式配置信息如下1、 cxf用的jar包http:/cxf.apache.org/download.html可以下载到。2、web.xml CXFServlet CXF Servlet org.apache.cxf.transport.servlet.CXFServlet 1 CXFServlet /service/* 3、配置文件applicationContext-service.xml(注意红色部分为配置文件新加配置)beans xmlns=http:/www.springframework.org/schema/beans xmlns:xsi=http:/www.w3.org/2001/XMLSchema-instance xmlns:jaxws=http:/cxf.apache.org

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2