我在JBossEAP6.2上安装了一个WebService。当我想获取SOAP头时会出现问题。
代码,在出现异常时:
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.
}我知道它不是很漂亮,但是我非常感兴趣的是在这个方法中获取标题和异常。
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>但我觉得效果很好。
那么我的问题是:如何避免呢?有谁可以帮我?谢谢
发布于 2014-05-03 19:51:49
找到了解决方案,只需添加其他库,而不是通常的apache绑定:
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-jaxws</artifactId>
<version>2.0.1.SP2</version>
</dependency>
<dependency>
<groupId>org.jboss.ws.cxf</groupId>
<artifactId>jbossws-cxf-server</artifactId>
<version>4.2.0.Alpha1</version>
<scope>provided</scope>
</dependency>发布于 2014-03-25 12:40:57
可能存在间接依赖。您的一个模块或库也可以具有依赖org.apache.cxf。
试着找出是否有多个版本。最简单的方法是检查所有的目标脏,并找到所有的罐子。然后比较版本并排除不正确的版本。
<exclusions>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>2.4.2</version>
</exclusion>
</exclusions>另外,JBoss也可能以某种方式拥有这个库。
https://stackoverflow.com/questions/22634730
复制相似问题