java - org.apache.cxf.binding.soap.SoapHeader 无法转换为 org.apache.cxf.binding.soap.SoapHeader

标签 java maven jboss soapheader

我在 JBOSS EAP 6.2 上安装了一个 WebService。当我想获取 SOAP header 时出现问题。

引发异常的代码:

 ArrayList<SoapHeader> hl = (ArrayList<SoapHeader>) wsctx.getMessageContext().get("org.apache.cxf.headers.Header.list");
    String username = "";
    String password = "";

    for (int i = 0; i < hl.size(); i++) { //for(SoapHeader header : hl) gives this same exception
        SoapHeader header = hl.get(i);
        //here is fetching data from this header. Not important to this case.
    }

我知道它不太漂亮,但我真的有兴趣获取 header 和在此方法中准确引发的异常:

hl.get(i)

异常消息是:

 org.apache.cxf.binding.soap.SoapHeader cannot be cast to org.apache.cxf.binding.soap.SoapHeader

起初我认为我的 Maven 的 POM 文件版本错误,所以:

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-bindings-soap</artifactId>
        <version>2.4.2</version>
    </dependency>

但我认为效果很好。

所以我的问题:如何避免它?谁能帮我?谢谢

最佳答案

可能存在间接依赖性。您的模块或库之一也可能具有依赖项 org.apache.cxf

尝试弄清楚是否存在多个版本。最简单的方法是检查所有目标目录并找到所有 jar 。然后比较版本并排除不正确的

  <exclusions>
    <exclusion>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-bindings-soap</artifactId>
      <version>2.4.2</version>
    </exclusion>
  </exclusions>

此外,JBoss 也可能以某种方式拥有该库。

关于java - org.apache.cxf.binding.soap.SoapHeader 无法转换为 org.apache.cxf.binding.soap.SoapHeader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22634730/

相关文章:

Java class.getResourceAsStream() 返回不正确的字节

通过 jdbc 调用时 Oracle 存储过程挂起

java - 基于 Maven 的 JAX WS 项目无法在 Eclipse 中运行

java - 流口水为什么 StatefulKnowledgeSession 有不同的知识库

java - 我如何将 bytearray 存储为 HashMap 中的值?

java - Hello World Java 小程序不会在 Ubuntu 的 Firefox 中显示

java - Maven:如何在父 POM 中引用子项目的构建目录?

java - 如何使用Java中的Comparable接口(interface)按参数对对象数组进行排序?

java - Spring集成+发送2个事件到kafka

spring - mvn Spring 启动 :run vs Run