CXF 2.4.2:找不到命名空间http://schemas.xmlsoap.org/soap/http的管道启动器

Dan*_*ber 21 java soap cxf

我有一个从wsdl生成的服务客户端.我正在尝试呼叫远程服务,我收到下面看到的导管启动器错误.我尝试了许多解决方案但没有成功.

我找到了推荐使用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>
Run Code Online (Sandbox Code Playgroud)

此配置提供有关如何配置传输工厂并将其绑定到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)
Run Code Online (Sandbox Code Playgroud)

预防措施:此时,我将停止尝试将我的CXF客户端升级到2.4.2并回退到最老的版本(2.2系列).这不太理想.

我想继续升级.有关如何配置CXF 2.4.X的任何建议,以便我的客户端HTTP SOAP配置正确连接将非常适合.

小智 24

就像旧帖子推荐的那样,这可以通过在混合中添加cxf-rt-transports-http-jetty来解决.

  • 有人知道这种依赖性需要的原因是什么?我有这样的情况,在Intellij IDE一切正常,但maven surefire不起作用.Intellij JUnit运行器是否具有此依赖性? (7认同)
  • 添加cxf-rt-transports-http的依赖项要少得多,同样也可以. (4认同)
  • cxf-rt-transports-http已经添加,但仍然是同样的错误.在tomcat中运行它 (2认同)

Dmi*_*kiy 16

客户端上的无效url格式可能会产生此错误.例如,如果使用http传输,则应定义"http:// localhost:8080/services/{smth}"url.如果你定义没有http前缀的"localhost:8080/services/{smth}" - 你会收到这样的错误.

  • 或 URL 中的多余空格 (2认同)

Dil*_*ana 5

我也面临着同样的问题。通过 IntelliJ,一切工作正常,但 Maven Surefire 抛出错误。并终于找到了答案。这里是:

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

将其添加到 pom 的插件部分的构建部分:

  <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>
Run Code Online (Sandbox Code Playgroud)