java - Apache CXF 异常 : java. lang.RuntimeException:找不到地址的管道启动器

标签 java web-services soap wsdl cxf

我想从 Java 调用 .net SOAP Web 服务。 .net 服务有 ws-security 模块,我使用 apache CXF 来设置用户名和密码(也许以后还有 X.509 证书)。我使用的代码是:

    ITaxOrganService wsHttpBindingITaxOrganService = new TaxOrganService().getWSHttpBindingITaxOrganService();
    Endpoint endpoint = ClientProxy.getClient(wsHttpBindingITaxOrganService).getEndpoint();

    Map<String,Object> outProps = new HashMap<>();
    outProps.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER,"*****");
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
    outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ShahrdariPasswordCallback.class.getName());

    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    endpoint.getOutInterceptors().add(wssOut);
    PermissionPrintDS permissionPrintDS = wsHttpBindingITaxOrganService.providePermissionInfoByPermNo(10000198);

但是 java 在最后一行抛出异常:

    Caused by: java.lang.RuntimeException: Could not find conduit initiator for address: http://urbanservices.iri/Services/xxyzService/xxyzService.svc and transport: http://schemas.xmlsoap.org/soap/http
    at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:224) ~[cxf-rt-bindings-soap-3.1.0.jar:3.1.0]
    at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:229) ~[cxf-rt-bindings-soap-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.AbstractConduitSelector.createConduit(AbstractConduitSelector.java:145) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:107) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:853) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:511) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279) ~[cxf-core-3.1.0.jar:3.1.0]
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) ~[cxf-rt-frontend-simple-3.1.0.jar:3.1.0]
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139) ~[cxf-rt-frontend-jaxws-3.1.0.jar:3.1.0]
    at com.sun.proxy.$Proxy144.providePermissionInfoByPermNo(Unknown Source) ~[na:na]

我能做什么?

最佳答案

我在我的 java 项目中遇到了同样的问题。

首先,我的 pom.xml 中只有以下 CXF 依赖项:

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>${cxf.version}</version>
</dependency>

然后,我添加了两个 CXF 依赖项:

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>${cxf.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http-jetty</artifactId>
    <version>${cxf.version}</version>
</dependency>

完整的 pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>fr.atatorus</groupId>
    <artifactId>bookclient</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <cxf.version>2.2.3</cxf.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
        </dependency>
    </dependencies>
</project>

此配置帮助我的项目正常工作。

关于java - Apache CXF 异常 : java. lang.RuntimeException:找不到地址的管道启动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30284377/

相关文章:

java - Lucene 3.6 和用于特殊字符的自定义分词器/分析器

java - Google App Engine 的 .net 包装器?

Node.js 中的 SOAP

java - 运行程序并输入正确的输入后,程序不会显示程序的答案

java - 如何在 Maybe.create(emitter) 中发出 Maybe.empty ?

java - Web 服务 CXF 错误 MalformedURIException

java - 抛出 WSDL 中未提及的 SOAP 错误

java - "Hello World"使用 Spring MVC 的 SOAP Web 服务

web-services - 选择 REST 风格 Web 服务而不是 Soap 的论点

java - 在调用子类构造函数之前,编译器是否会在子类构造函数中查找 **super** 关键字?