首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

CXF 2.0 学习笔记-三 SOAP Header

2014-01-03 
CXF 2.0 学习笔记-3 SOAP Headerpackage?hs.cxf.soapHeaderimport?javax.xml.soap.SOAPExceptionimport?

CXF 2.0 学习笔记-3 SOAP Header
package?hs.cxf.soapHeader;
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Headerimport?javax.xml.soap.SOAPException;
CXF 2.0 学习笔记-三 SOAP Headerimport?javax.xml.soap.SOAPHeader;
CXF 2.0 学习笔记-三 SOAP Headerimport?javax.xml.soap.SOAPMessage;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.binding.soap.SoapMessage;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.interceptor.Fault;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.phase.AbstractPhaseInterceptor;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.phase.Phase;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.w3c.dom.NodeList;
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header/**
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Title:获取soap头信息
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Description:
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Copyright:
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@author?zz
CXF 2.0 学习笔记-三 SOAP Header?*?@version?1.00.000
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*/
CXF 2.0 学习笔记-三 SOAP Headerpublic?class?ReadSoapHeader?extends?AbstractPhaseInterceptor<SoapMessage>?{
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????private?SAAJInInterceptor?saa?=?new?SAAJInInterceptor();
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????public?ReadSoapHeader()?{
CXF 2.0 学习笔记-三 SOAP Header????????super(Phase.PRE_PROTOCOL);
CXF 2.0 学习笔记-三 SOAP Header????????getAfter().add(SAAJInInterceptor.class.getName());
CXF 2.0 学习笔记-三 SOAP Header????}
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????public?void?handleMessage(SoapMessage?message)?throws?Fault?{
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????SOAPMessage?mess?=?message.getContent(SOAPMessage.class);
CXF 2.0 学习笔记-三 SOAP Header????????if?(mess?==?null)?{
CXF 2.0 学习笔记-三 SOAP Header????????????saa.handleMessage(message);
CXF 2.0 学习笔记-三 SOAP Header????????????mess?=?message.getContent(SOAPMessage.class);
CXF 2.0 学习笔记-三 SOAP Header????????}
CXF 2.0 学习笔记-三 SOAP Header????????SOAPHeader?head?=?null;
CXF 2.0 学习笔记-三 SOAP Header????????try?{
CXF 2.0 学习笔记-三 SOAP Header????????????head?=?mess.getSOAPHeader();
CXF 2.0 学习笔记-三 SOAP Header????????}?catch?(SOAPException?e)?{
CXF 2.0 学习笔记-三 SOAP Header????????????e.printStackTrace();
CXF 2.0 学习笔记-三 SOAP Header????????}
CXF 2.0 学习笔记-三 SOAP Header????????if?(head?==?null)?{
CXF 2.0 学习笔记-三 SOAP Header????????????return;
CXF 2.0 学习笔记-三 SOAP Header????????}
CXF 2.0 学习笔记-三 SOAP Header????????try?{
CXF 2.0 学习笔记-三 SOAP Header????????????//读取自定义的节点
CXF 2.0 学习笔记-三 SOAP Header????????????NodeList?nodes?=?head.getElementsByTagName("tns:spId");
CXF 2.0 学习笔记-三 SOAP Header????????????NodeList?nodepass?=?head.getElementsByTagName("tns:spPassword");
CXF 2.0 学习笔记-三 SOAP Header????????????//获取节点值,简单认证
CXF 2.0 学习笔记-三 SOAP Header????????????if?(nodes.item(0).getTextContent().equals("wdw"))?{
CXF 2.0 学习笔记-三 SOAP Header????????????????if?(nodepass.item(0).getTextContent().equals("wdwsb"))?{
CXF 2.0 学习笔记-三 SOAP Header????????????????????System.out.println("认证成功");
CXF 2.0 学习笔记-三 SOAP Header????????????????}
CXF 2.0 学习笔记-三 SOAP Header????????????}?else?{
CXF 2.0 学习笔记-三 SOAP Header????????????????SOAPException?soapExc?=?new?SOAPException("认证错误");
CXF 2.0 学习笔记-三 SOAP Header????????????????throw?new?Fault(soapExc);
CXF 2.0 学习笔记-三 SOAP Header????????????}
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????}?catch?(Exception?e)?{
CXF 2.0 学习笔记-三 SOAP Header????????????SOAPException?soapExc?=?new?SOAPException("认证错误");
CXF 2.0 学习笔记-三 SOAP Header????????????throw?new?Fault(soapExc);
CXF 2.0 学习笔记-三 SOAP Header????????}
CXF 2.0 学习笔记-三 SOAP Header????}
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header}


2.配置文件中新增拦截器配置

CXF 2.0 学习笔记-三 SOAP Header<beans?xmlns="http://www.springframework.org/schema/beans"??
CXF 2.0 学习笔记-三 SOAP Header????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"??
CXF 2.0 学习笔记-三 SOAP Header????xmlns:jaxws="http://cxf.apache.org/jaxws"??
CXF 2.0 学习笔记-三 SOAP Header????xsi:schemaLocation="???
CXF 2.0 学习笔记-三 SOAP Headerhttp://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans.xsd???
CXF 2.0 学习笔记-三 SOAP Headerhttp://cxf.apache.org/jaxws?http://cxf.apache.org/schemas/jaxws.xsd">???
CXF 2.0 学习笔记-三 SOAP Header??
CXF 2.0 学习笔记-三 SOAP Header????<import?resource="classpath:META-INF/cxf/cxf.xml"?/>???
CXF 2.0 学习笔记-三 SOAP Header????<import?resource="classpath:META-INF/cxf/cxf-extension-soap.xml"?/>???
CXF 2.0 学习笔记-三 SOAP Header????<import?resource="classpath:META-INF/cxf/cxf-servlet.xml"?/>???
CXF 2.0 学习笔记-三 SOAP Header??
CXF 2.0 学习笔记-三 SOAP Header????<bean?id="jaxWsServiceFactoryBean"??
CXF 2.0 学习笔记-三 SOAP Header????????class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">???
CXF 2.0 学习笔记-三 SOAP Header????????<property?name="wrapped"?value="true"?/>???
CXF 2.0 学习笔记-三 SOAP Header????????<property?name="dataBinding"?ref="aegisBean"?/>???
CXF 2.0 学习笔记-三 SOAP Header????</bean>???
CXF 2.0 学习笔记-三 SOAP Header??
CXF 2.0 学习笔记-三 SOAP Header????<bean?id="aegisBean"??
CXF 2.0 学习笔记-三 SOAP Header????????class="org.apache.cxf.aegis.databinding.AegisDatabinding"?/>???
CXF 2.0 学习笔记-三 SOAP Header??
CXF 2.0 学习笔记-三 SOAP Header????<jaxws:endpoint?id="CollectiveServices"??
CXF 2.0 学习笔记-三 SOAP Header????????implementor="hs.cxf.server.WebServiceSampleImpl"?address="/HelloWorld">???
CXF 2.0 学习笔记-三 SOAP Header????????<jaxws:inInterceptors>???
CXF 2.0 学习笔记-三 SOAP Header??????????<!--?日志拦截器?-->??????
CXF 2.0 学习笔记-三 SOAP Header??????????<bean?alt="CXF 2.0 学习笔记-三 SOAP Header">??????????<!--?自定义拦截器?-->?
CXF 2.0 学习笔记-三 SOAP Header??????????<bean?alt="CXF 2.0 学习笔记-三 SOAP Header">??????????</jaxws:inInterceptors>????
CXF 2.0 学习笔记-三 SOAP Header????????<jaxws:serviceFactory>???
CXF 2.0 学习笔记-三 SOAP Header????????????<ref?bean="jaxWsServiceFactoryBean"/>???
CXF 2.0 学习笔记-三 SOAP Header????????</jaxws:serviceFactory>???
CXF 2.0 学习笔记-三 SOAP Header????</jaxws:endpoint>???
CXF 2.0 学习笔记-三 SOAP Header</beans>??
CXF 2.0 学习笔记-三 SOAP Header


服务端的配置就告一段落了,接下来是客户端的修改
客户端
1.同样新增一个Interceptor

CXF 2.0 学习笔记-三 SOAP Headerpackage?hs.cxf.client.SoapHeader;
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Headerimport?java.util.List;
CXF 2.0 学习笔记-三 SOAP Headerimport?javax.xml.namespace.QName;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.binding.soap.SoapHeader;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.binding.soap.SoapMessage;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.headers.Header;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.helpers.DOMUtils;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.interceptor.Fault;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.phase.Phase;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.w3c.dom.Document;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.w3c.dom.Element;
CXF 2.0 学习笔记-三 SOAP Header/**
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Title:在发送消息前,封装Soap?Header?信息
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Description:
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Copyright:?
CXF 2.0 学习笔记-三 SOAP Header?*
CXF 2.0 学习笔记-三 SOAP Header?*?@author?zz
CXF 2.0 学习笔记-三 SOAP Header?*?@version?1.00.000
CXF 2.0 学习笔记-三 SOAP Header?*
CXF 2.0 学习笔记-三 SOAP Header?*/
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Headerpublic?class?AddSoapHeader?extends?AbstractSoapInterceptor?{
CXF 2.0 学习笔记-三 SOAP Header??????private?static?String?nameURI="http://127.0.0.1:8080/cxfTest/ws/HelloWorld";???
CXF 2.0 学习笔记-三 SOAP Header??????
CXF 2.0 学习笔记-三 SOAP Header????????public?AddSoapHeader(){???
CXF 2.0 学习笔记-三 SOAP Header????????????super(Phase.WRITE);???
CXF 2.0 学习笔记-三 SOAP Header????????}???
CXF 2.0 学习笔记-三 SOAP Header????????
CXF 2.0 学习笔记-三 SOAP Header????????public?void?handleMessage(SoapMessage?message)?throws?Fault?{???
CXF 2.0 学习笔记-三 SOAP Header????????????String?spPassword="wdwsb";???
CXF 2.0 学习笔记-三 SOAP Header????????????String?spName="wdw";???
CXF 2.0 学习笔记-三 SOAP Header???????????????
CXF 2.0 学习笔记-三 SOAP Header????????????QName?qname=new?QName("RequestSOAPHeader");???
CXF 2.0 学习笔记-三 SOAP Header????????????Document?doc=DOMUtils.createDocument();???
CXF 2.0 学习笔记-三 SOAP Header????????????//自定义节点
CXF 2.0 学习笔记-三 SOAP Header????????????Element?spId=doc.createElement("tns:spId");???
CXF 2.0 学习笔记-三 SOAP Header????????????spId.setTextContent(spName);???
CXF 2.0 学习笔记-三 SOAP Header????????????//自定义节点
CXF 2.0 学习笔记-三 SOAP Header????????????Element?spPass=doc.createElement("tns:spPassword");???
CXF 2.0 学习笔记-三 SOAP Header????????????spPass.setTextContent(spPassword);???
CXF 2.0 学习笔记-三 SOAP Header???????????????
CXF 2.0 学习笔记-三 SOAP Header????????????Element?root=doc.createElementNS(nameURI,?"tns:RequestSOAPHeader");???
CXF 2.0 学习笔记-三 SOAP Header????????????root.appendChild(spId);???
CXF 2.0 学习笔记-三 SOAP Header????????????root.appendChild(spPass);???
CXF 2.0 学习笔记-三 SOAP Header???????????????
CXF 2.0 学习笔记-三 SOAP Header????????????SoapHeader?head=new?SoapHeader(qname,root);???
CXF 2.0 学习笔记-三 SOAP Header????????????List<Header>?headers=message.getHeaders();???
CXF 2.0 学习笔记-三 SOAP Header????????????headers.add(head);???
CXF 2.0 学习笔记-三 SOAP Header????????????System.out.println(">>>>>添加header<<<<<<<");
CXF 2.0 学习笔记-三 SOAP Header????????}???
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header}
CXF 2.0 学习笔记-三 SOAP Header


2.客户端调用程序修改

CXF 2.0 学习笔记-三 SOAP Headerpackage?hs.cxf.client;
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Headerimport?hs.cxf.client.SoapHeader.AddSoapHeader;
CXF 2.0 学习笔记-三 SOAP Headerimport?java.util.ArrayList;
CXF 2.0 学习笔记-三 SOAP Headerimport?javax.xml.bind.JAXBElement;
CXF 2.0 学习笔记-三 SOAP Headerimport?javax.xml.namespace.QName;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.endpoint.Client;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.frontend.ClientProxy;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.interceptor.Interceptor;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.transport.http.HTTPConduit;
CXF 2.0 学习笔记-三 SOAP Headerimport?org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header/**
CXF 2.0 学习笔记-三 SOAP Header?*?@Title:
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Description:
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@Copyright:?
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*?@author?zz
CXF 2.0 学习笔记-三 SOAP Header?*?@version?1.00.000
CXF 2.0 学习笔记-三 SOAP Header?*?
CXF 2.0 学习笔记-三 SOAP Header?*/
CXF 2.0 学习笔记-三 SOAP Headerpublic?class?TestClient?{
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????/**
CXF 2.0 学习笔记-三 SOAP Header?????*?测试1
CXF 2.0 学习笔记-三 SOAP Header?????*/
CXF 2.0 学习笔记-三 SOAP Header????@SuppressWarnings("unchecked")
CXF 2.0 学习笔记-三 SOAP Header????public?void?testSend1()?{
CXF 2.0 学习笔记-三 SOAP Header????????try?{
CXF 2.0 学习笔记-三 SOAP Header????????????JaxWsProxyFactoryBean?factory?=?new?JaxWsProxyFactoryBean();
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????????ArrayList<Interceptor>?list?=?new?ArrayList<Interceptor>();
CXF 2.0 学习笔记-三 SOAP Header????????????//?添加soap?header?
CXF 2.0 学习笔记-三 SOAP Header????????????list.add(new?AddSoapHeader());
CXF 2.0 学习笔记-三 SOAP Header????????????//?添加soap消息日志打印
CXF 2.0 学习笔记-三 SOAP Header????????????list.add(new?org.apache.cxf.interceptor.LoggingOutInterceptor());
CXF 2.0 学习笔记-三 SOAP Header????????????factory.setOutInterceptors(list);
CXF 2.0 学习笔记-三 SOAP Header????????????factory.setServiceClass(WebServiceSample.class);
CXF 2.0 学习笔记-三 SOAP Header????????????factory.setAddress("http://127.0.0.1:8080/cxfTest/ws/HelloWorld");
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????????Object?obj?=?factory.create();
CXF 2.0 学习笔记-三 SOAP Header????????????System.out.println(obj?==?null???"NULL"?:?obj.getClass().getName());
CXF 2.0 学习笔记-三 SOAP Header????????????if?(obj?!=?null)?{
CXF 2.0 学习笔记-三 SOAP Header????????????????WebServiceSample?ws?=?(WebServiceSample)?obj;
CXF 2.0 学习笔记-三 SOAP Header????????????????String?str?=?ws.say("test");
CXF 2.0 学习笔记-三 SOAP Header????????????????System.out.println(str);
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????????????str?=?ws.say("1111");
CXF 2.0 学习笔记-三 SOAP Header????????????????System.out.println(str);
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????????????User?u?=?new?User();
CXF 2.0 学习笔记-三 SOAP Header????????????????JAXBElement<String>?je?=?new?JAXBElement<String>(new?QName(
CXF 2.0 学习笔记-三 SOAP Header????????????????????????"http://bean.cxf.hs",?"name"),?String.class,?"张三");
CXF 2.0 学习笔记-三 SOAP Header????????????????u.setName(je);
CXF 2.0 学习笔记-三 SOAP Header????????????????str?=?ws.sayUserName(u);
CXF 2.0 学习笔记-三 SOAP Header????????????????System.out.println(str);
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????????????//?通过对象来交互
CXF 2.0 学习笔记-三 SOAP Header????????????????ReqBean?req?=?new?ReqBean();
CXF 2.0 学习笔记-三 SOAP Header????????????????req.setExp(new?JAXBElement<String>(new?QName(
CXF 2.0 学习笔记-三 SOAP Header????????????????????????"http://bean.cxf.hs",?"exp"),?String.class,
CXF 2.0 学习笔记-三 SOAP Header????????????????????????"<exp>111<exp>"));
CXF 2.0 学习笔记-三 SOAP Header????????????????req.setSeqId(new?JAXBElement<String>(new?QName(
CXF 2.0 学习笔记-三 SOAP Header????????????????????????"http://bean.cxf.hs",?"seqId"),?String.class,
CXF 2.0 学习笔记-三 SOAP Header????????????????????????"12345678"));
CXF 2.0 学习笔记-三 SOAP Header????????????????RespBean?resp?=?ws.action(req);
CXF 2.0 学习笔记-三 SOAP Header????????????????System.out.println("resp_id:"?+?resp.getRespId().getValue());
CXF 2.0 学习笔记-三 SOAP Header????????????????System.out.println("resp_exp:"?+?resp.getExp().getValue());
CXF 2.0 学习笔记-三 SOAP Header????????????}
CXF 2.0 学习笔记-三 SOAP Header????????}?catch?(Exception?ex)?{
CXF 2.0 学习笔记-三 SOAP Header????????????ex.printStackTrace();
CXF 2.0 学习笔记-三 SOAP Header????????}
CXF 2.0 学习笔记-三 SOAP Header????}
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????/**
CXF 2.0 学习笔记-三 SOAP Header?????*?测试2
CXF 2.0 学习笔记-三 SOAP Header?????*/
CXF 2.0 学习笔记-三 SOAP Header????@SuppressWarnings("unchecked")
CXF 2.0 学习笔记-三 SOAP Header????public?void?testSend2()?{
CXF 2.0 学习笔记-三 SOAP Header????????String?webServiceUrl?=?"http://127.0.0.1:8080/cxfTest/ws/HelloWorld";
CXF 2.0 学习笔记-三 SOAP Header????????String?webServiceConTimeout?=?"60000";
CXF 2.0 学习笔记-三 SOAP Header????????String?webServiceRevTimeout?=?"60000";
CXF 2.0 学习笔记-三 SOAP Header????????JaxWsProxyFactoryBean?factory?=?new?JaxWsProxyFactoryBean();
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????ArrayList<Interceptor>?list?=?new?ArrayList<Interceptor>();
CXF 2.0 学习笔记-三 SOAP Header????????//?添加soap?header?信息
CXF 2.0 学习笔记-三 SOAP Header????????list.add(new?AddSoapHeader());
CXF 2.0 学习笔记-三 SOAP Header????????//?添加soap消息日志打印
CXF 2.0 学习笔记-三 SOAP Header????????list.add(new?org.apache.cxf.interceptor.LoggingOutInterceptor());
CXF 2.0 学习笔记-三 SOAP Header????????factory.setOutInterceptors(list);
CXF 2.0 学习笔记-三 SOAP Header????????factory.setServiceClass(WebServiceSample.class);
CXF 2.0 学习笔记-三 SOAP Header????????factory.setAddress(webServiceUrl);
CXF 2.0 学习笔记-三 SOAP Header????????WebServiceSample?service?=?(WebServiceSample)?factory.create();
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????????//超时时间设置
CXF 2.0 学习笔记-三 SOAP Header????????Client?clientP?=?ClientProxy.getClient(service);
CXF 2.0 学习笔记-三 SOAP Header????????HTTPConduit?http?=?(HTTPConduit)?clientP.getConduit();
CXF 2.0 学习笔记-三 SOAP Header????????HTTPClientPolicy?httpClientPolicy?=?new?HTTPClientPolicy();
CXF 2.0 学习笔记-三 SOAP Header????????httpClientPolicy.setConnectionTimeout(Integer
CXF 2.0 学习笔记-三 SOAP Header????????????????.valueOf(webServiceConTimeout));
CXF 2.0 学习笔记-三 SOAP Header????????httpClientPolicy.setReceiveTimeout(Integer
CXF 2.0 学习笔记-三 SOAP Header????????????????.valueOf(webServiceRevTimeout));
CXF 2.0 学习笔记-三 SOAP Header????????httpClientPolicy.setAllowChunking(false);
CXF 2.0 学习笔记-三 SOAP Header????????http.setClient(httpClientPolicy);
CXF 2.0 学习笔记-三 SOAP Header????????
CXF 2.0 学习笔记-三 SOAP Header????
CXF 2.0 学习笔记-三 SOAP Header????????//?通过对象来交互
CXF 2.0 学习笔记-三 SOAP Header????????ReqBean?req?=?new?ReqBean();
CXF 2.0 学习笔记-三 SOAP Header????????req.setExp(new?JAXBElement<String>(new?QName(
CXF 2.0 学习笔记-三 SOAP Header????????????????"http://bean.cxf.hs",?"exp"),?String.class,
CXF 2.0 学习笔记-三 SOAP Header????????????????"<exp>111<exp>"));
CXF 2.0 学习笔记-三 SOAP Header????????req.setSeqId(new?JAXBElement<String>(new?QName(
CXF 2.0 学习笔记-三 SOAP Header????????????????"http://bean.cxf.hs",?"seqId"),?String.class,
CXF 2.0 学习笔记-三 SOAP Header????????????????"12345678"));
CXF 2.0 学习笔记-三 SOAP Header????????System.out.println(">>>>>>发送消息<<<<<<<<<");
CXF 2.0 学习笔记-三 SOAP Header????????RespBean?resp?=?service.action(req);
CXF 2.0 学习笔记-三 SOAP Header????????System.out.println("resp_id:"?+?resp.getRespId().getValue());
CXF 2.0 学习笔记-三 SOAP Header????????System.out.println("resp_exp:"?+?resp.getExp().getValue());
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????}
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header????/**
CXF 2.0 学习笔记-三 SOAP Header?????*?@param?args
CXF 2.0 学习笔记-三 SOAP Header?????*/
CXF 2.0 学习笔记-三 SOAP Header????public?static?void?main(String[]?args)?{
CXF 2.0 学习笔记-三 SOAP Header????????TestClient?tc?=?new?TestClient();
CXF 2.0 学习笔记-三 SOAP Header????????tc.testSend1();
CXF 2.0 学习笔记-三 SOAP Header????????System.out.println(">>>>>>>>>>>>2<<<<<<<<<<<<<");
CXF 2.0 学习笔记-三 SOAP Header????????tc.testSend2();
CXF 2.0 学习笔记-三 SOAP Header????????System.out.println(">>>>>>>>>>>>END<<<<<<<<<<<<<");
CXF 2.0 学习笔记-三 SOAP Header????}
CXF 2.0 学习笔记-三 SOAP Header
CXF 2.0 学习笔记-三 SOAP Header}


到这里就结束了,可以进行测试了

热点排行