如何解决类转换异常 org.apache.cxf.jaxws.JaxWsClientProxy 不能转换为 org.apache.cxf.frontend.ClientProxy
我的要求是从两个不同的服务中调用第三方soap web 服务。我从提供的 wsdl 创建了一个客户端(使用 cxf-codegen-plugin),并使用来自我的两个服务的相同客户端。它适用于一项服务,而不适用于另一项服务。这两个服务都部署在同一个 JBoss EAP 6.4 中。
我尝试在提供的范围内添加与 cxf 相关的依赖项,以便可以从 jboss 模块中选择它,但在这种情况下,我发现类未找到异常。
我在这一行运行时遇到以下错误
org.apache.cxf.endpoint.Client 客户端 = ClientProxy.getClient(bp);
08:44:21,718 错误 [stderr] (http-localhost/127.0.0.1:8080-1) java.lang.ClassCastException: org.apache.cxf.jaxws.JaxWsClientProxy 无法转换为 org.apache.cxf。前端.ClientProxy
08:44:21,718 错误 [stderr] (http-localhost/127.0.0.1:8080-1) 在 org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:127)
下面是我的方法
public void configure(String endpointUrl,BindingProvider bp) {
try {
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,endpointUrl);
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,"AUTH_USERNAME");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,"AUTH_PASSWORD");
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(getHandler());
bp.getBinding().setHandlerChain(handlerChain);
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(bp);
org.apache.cxf.transport.http.HTTPConduit conduit = (HTTPConduit) client.getConduit();
conduit.getClient().setProxyServer(PROXY_URL);
conduit.getClient().setProxyServerPort(Integer.valueOf(PROXY_PORT));
} catch (Exception exception) {
exception.printStackTrace();
}
}
我的 pom.xml 依赖
<dependency>
<groupId>org.apache.cxf.xjc-utils</groupId>
<artifactId>cxf-xjc-runtime</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.4.1</version>
<exclusions>
<exclusion>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-hc</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-jaxb</artifactId>
<version>3.4.1</version>
<exclusions>
<exclusion>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
任何帮助/指示将不胜感激。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。