类转换异常 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...