CXF 2.4.2:在命名空间http://schemas.xmlsoap.org/soap/http中未找到任何导管初始化程序。

22

我有一个从wsdl生成的服务客户端。我尝试调用远程服务,但是收到了下面看到的conduit initiator错误。我尝试了很多解决方案都没有成功。

我找到了一些(旧的帖子)解决方案,建议使用http-jetty扩展。我不认为这对我有意义,因为服务器不在本地运行。

我还发现最接近帮助我的配置是一个包含以下内容的示例cxf.xml文件:

<bean class="org.apache.cxf.transport.local.LocalTransportFactory"
    lazy-init="false">
    <property name="transportIds">
        <list>
            <value>http://cxf.apache.org/transports/local</value>
            <value>http://cxf.apache.org/transports/http</value>
            <value>http://schemas.xmlsoap.org/soap/http</value>
            <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
        </list>
    </property>
</bean>

此配置提供如何配置传输工厂并将其绑定到http://schemas.xmlsoap.org/soap/http的指导。当我尝试使用HTTPTransportFactory时,会收到初始化失败的异常(无此方法错误)。

Caused by: org.apache.cxf.BusException: No conduit initiator was found for the namespace http://schemas.xmlsoap.org/soap/http.
    at org.apache.cxf.transport.ConduitInitiatorManagerImpl.getConduitInitiator(ConduitInitiatorManagerImpl.java:112)
    at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:73)
    at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:61)
    at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:708)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:476)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:309)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:261)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:127)

注意: 我现在会停止升级我的CXF客户端到2.4.2,并回退到最早可用的版本(2.2系列)。这并不理想。

我希望能够继续进行升级。如果对如何配置CXF 2.4.X以使我的仅客户端的HTTP SOAP配置正确连接有任何建议,将不胜感激。

8个回答

26

像旧帖子中所推荐的那样,这可以通过将cxf-rt-transports-http-jetty集成到混合中来解决。


很好。在Eclipse中直接运行JUnit测试没有问题,但需要添加此依赖项(具有测试范围)才能从命令行运行单元测试:mvn test。 - majorbanzai
4
添加cxf-rt-transports-http的依赖更少,而且同样有效。 - AlexV
2
cxf-rt-transports-http已经被添加,但仍然出现相同的错误。在Tomcat中运行此操作。 - Daniel Bo
7
有人知道为什么需要这个依赖吗?在Intellij IDE中一切正常,但maven surefire却不能正常工作。是不是Intellij JUnit运行器也需要这个依赖? - Przemek Nowak

20

此错误可能由客户端上的无效URL格式导致。例如,如果您使用http传输协议,则应定义"http://localhost:8080/services/{smth}" URL。如果未加http前缀定义"localhost:8080/services/{smth}",则会收到此类错误。


2
或者在URL中添加一个额外的空格 - Ignacio A. Poletti
1
我的属性值中有额外的空格,导致了这个问题。 - Anand

5

我也遇到了同样的问题。在IntelliJ中一切都运行良好,但maven surefire却抛出了错误。最后找到了答案。如下:

基本上,每个cxf库都提供一个META-INF/cxf/bus-extensions.txt文件,而打包工具的默认行为是替换该文件,导致它不完整。通过将shader配置为附加而不是替换cxf内容,cxf的行为将正确。

在插件部分的构建部分中添加以下内容:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.4</version>
    <configuration>
      <createDependencyReducedPom>true</createDependencyReducedPom>
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/cxf/bus-extensions.txt</resource>
            </transformer>
          </transformers>
          <filters>
            <filter>
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
              </excludes>
            </filter>
          </filters>
        </configuration>
      </execution>
    </executions>
  </plugin>

4

你是否将cxf-rt-binding-soap-2.4.x.jar放入了你的类路径中?


是的(谢谢您的回复!)。在我的MAVEN POM中,我有:<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-bindings-soap</artifactId> <version>${cxf.version}</version> </dependency> - Dan Barber
如果你有那个依赖项,你就不应该有这个问题 :) - Willem Jiang
我曾经遇到过一个问题,那就是SOAP服务和客户端在同一个JBoss上。重要的是要将这个依赖项添加到客户端模块中。 - Björn Landmesser
@WillemJiang:“如果你有这个依赖项,你就不应该有这个问题”,但即使在我的pom.xml中有cxf-rt-bindings-soap依赖项(以及cxf-rt-transports-httpcxf-rt-transports-http-jetty和一堆其他CXF依赖项),并且有一个100%有效的URL,我仍然在本地收到这个不清楚的错误消息(在服务器上部署时正常工作)... - Amos M. Carpenter

3
最近我将cxf-rt-ws-security升级到3.0.0,之后就开始出现org.apache.cxf.BusException报错:在命名空间http://schemas.xmlsoap.org/soap/http找不到传输通道初始化程序。 解决方法是在我的pom.xml中将以下jar包升级到3.0.0: cxf-rt-frontend-jaxws cxf-rt-ws-policy cxf-rt-transports-http

1
我曾遇到类似错误的情况,这个问题似乎是由以下旧版本的jar包引起的。
cxf-core-2.x.jar
cxf-rt-frontend-jaxrs-2.x.jar
cxf-rt-rs-client-2.x.jar
cxf-rt-transports-http-2.x.jar

当我切换到最新版本的这些jar包(在撰写时为3.2.1)后,已解决了错误。


将cxf-rt-transports-http添加到核心和前端库中,解决了我的问题。 - Mikhail Ionkin

1
这并不是针对原帖中列出的示例URL特定的情况,而是在URL不正确时出现了此错误。即,在URL路径中我们将某个字符串列两次而不是一次。

0

从我的POM中移除这个依赖项,问题就解决了

   <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.1.1</version>
    </dependency>

这意味着您已从CXF切换到JAX-WS的默认JDK实现。请参阅https://dev59.com/CWgu5IYBdhLWcg3wHjl7了解区别。 - Pino

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接