服务端:

    1.获取EndpointImpl对象

    2.调用EndpointImpl对象中的方法获取In拦截器
    3.调用EndpointImpl对象中的方法获取out拦截器

    4.添加自己的In拦截器与Out拦截器

      LogginInInterceptor:查看收到的消息包

      LoggOutInterceptor:查看发出去的消息包

客户端:

    需要导入cxf的7个jar包:

    1.获取client对象

      Client client=ClientProxy.getClient("ws服务组件代理对象") ---ws服务组件 就是  new 服务接口().getXxxPort();  就是服务端服务接口的实现类

    2.调用client对象中的方法获取In拦截器
    3.调用client对象中的方法获取out拦截器

    4.添加自己的In拦截器与Out拦截器

      LogginInInterceptor:查看收到的消息包

      LoggOutInterceptor:查看发出去的消息包

------------------------添加权限拦截器-----------------------------------

1.在soap包中添加Header元素,携带鉴定权限的数据

<Header>

  <auth>

    <auth_id>账号</auth_id>

    <auth_pwd>密码</auth_pwd>

  </auth>

</Header>

2.客户端------在发送soap包之前修改header头元素需要添加out拦截器

3.服务端------添加in拦截器解析soap包header头元素

4.自定义拦截器--需要继承AbstractPhaseInterceprot;

----------------------------自定义拦截器案例----------------------------

public class HeaderInterceptor extends AbstractPhaseInterceptor<SoapMessage> {
private String authId;
private String pwd;

public HeaderInterceptor(String authId, String pwd) {
/** 在发送soap包之前该拦截器起作用 */
super(Phase.PREPARE_SEND);
this.authId = authId;
this.pwd = pwd;
}

@Override
public void handleMessage(SoapMessage soapMessage) throws Fault {

/**
* <auth>
<auth_id>admin</auth_id>
<auth_pwd>888888</auth_id>
</auth>
*/
// 创建Document
Document doc = DOMUtils.createDocument();
// 创建Element
Element authEle = doc.createElement("auth");
Element idEle = doc.createElement("auth_id");
// 添加文本
idEle.setTextContent(authId);
Element pwdEle = doc.createElement("auth_pwd");
// 添加文本
pwdEle.setTextContent(pwd);

// 追加元素
authEle.appendChild(idEle);
authEle.appendChild(pwdEle);

// 创建Header头
Header header = new Header(new QName("it"), authEle);

// 获取所有的header头, 添加header头
soapMessage.getHeaders().add(header);

}

public String getAuthId() {
return authId;
}

public void setAuthId(String authId) {
this.authId = authId;
}

public String getPwd() {
return pwd;
}

public void setPwd(String pwd) {
this.pwd = pwd;
}

}

webservice拦截器 查看消息包(soap)的更多相关文章

  1. 5.webService拦截器

    CXF为什么要设计拦截器? 为了在webservice请求过程中,能动态操作请求和响应数据, CXF设计了拦截器. 拦截器分类 1.按所处的位置分:服务器端拦截器,客户端拦截器 2.按消息的方向分:入 ...

  2. 7.添加基于Spring的WebService拦截器

    客户端拦截器: public class AccountInterceptor extends AbstractPhaseInterceptor<SoapMessage>{ private ...

  3. 【WebService】WebService之CXF的拦截器(五)

    CXF拦截器介绍 CXF拦截器是功能的主要实现单元,也是主要的扩展点,可以在不对核心模块进行修改的情况下,动态添加功能.当服务被调用时,会经过多个拦截器链(Interceptor Chain)处理,拦 ...

  4. 使用CXF为webservice添加拦截器

      拦截器分为Service端和Client端 拦截器是在发送soap消息包的某一个时机拦截soap消息包,对soap消息包的数据进行分析或处理.分为CXF自带的拦截器和自定义的拦截器 1.Servi ...

  5. Struts 2 之拦截器

    拦截器概述 Struts2拦截器是在访问某个Action或Action的某个方法,字段之前或之后实施拦截,并且Struts2拦截器是可插拔的,拦截器是AOP(Aspect Oriented Progr ...

  6. struts2 自定义异常拦截器配log4j

    log4j.rootLogger = debug,stdout,F log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.app ...

  7. Struts2拦截器的使用 (详解)

    Struts2拦截器的使用 (详解) 如何使用struts2拦截器,或者自定义拦截器.特别注意,在使用拦截器的时候,在Action里面必须最后一定要引用struts2自带的拦截器缺省堆栈default ...

  8. struts2:拦截器

    拦截器(Interceptor)是Struts 2的核心组件,Struts 2框架的大部分功能都是通过拦截器来完成的,例如数据校验,国际化,文件上传和下载等.为了实现这些功能,Struts 2框架提供 ...

  9. struts拦截器的知识

    如何使用struts2拦截器,或者自定义拦截器.特别注意,在使用拦截器的时候,在Action里面必须最后一定要引用struts2自带的拦截器缺省堆栈defaultStack,如下(这里我是引用了str ...

随机推荐

  1. HDOJ/HDU 2700 Parity(奇偶判断~)

    Problem Description A bit string has odd parity if the number of 1's is odd. A bit string has even p ...

  2. this用法

    this是js的一个关键字,随着函数使用场合不同,this的值会发生变化.但是总有一个原则,那就是this指的是调用函数的那个对象. 1.纯粹函数调用. function test() { this. ...

  3. [LeetCode] Longest Valid Parentheses 解题思路

    Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...

  4. java对Ldap操作2

    package ldap.pojo;import java.util.List;/** * @author 张亮  * ldap用户属性信息数据类 */public class LdapPersonI ...

  5. 杭电 1795 The least one

    The least one Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. Mybatis 控制台打出Sql-Log的设置

    首先工程中必须要有slf4j-log4j12-1.7.12.jar这个包,否则打不出来 而后工程中“log4j.properties”文件如下: log4j.appender.stdout=org.a ...

  7. history对象back()、forward()、go()

    history对象back().forward().go()方法history.back() 功能:加载历史列表中的前一个URL(后退). 语法:history.back() 调用该方法的效果等价于点 ...

  8. Python3.x爬虫教程:爬网页、爬图片、自己主动登录

    林炳文Evankaka原创作品. 转载请注明出处http://blog.csdn.net/evankaka 摘要:本文将使用Python3.4爬网页.爬图片.自己主动登录.并对HTTP协议做了一个简单 ...

  9. JAAS authentication in Tomcat example--reference

    In this tutorial you will learn how to configure JAAS authentication in Tomcat using the HTTP Basic ...

  10. Java——(三)Collection之Set集合、HashSet类

    ------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- 一.Set集合 Set集合不允许包含相同的元素,如果试图把两个相同的元素加入同一个Set集合中, ...