【问题标题】:Camel CXF: Soap client timeoutCamel CXF:肥皂客户端超时
【发布时间】:2019-04-29 06:20:56
【问题描述】:

我正在使用 Camel CXF 端点连接到我的肥皂服务器。我想为来自客户的请求添加超时。我为此使用 continuationTimeout 选项。但它不起作用。请求超时,没有等待我配置的时间。

下面是我的端点配置。

<camel-cxf:cxfEndpoint id="tmAPIWSEndpoint" address="http://IN2NPDCEDB01:8088/webservices/services/TransportationManager"
            wsdlURL="/wsdl/TransportationManager.wsdl"
            endpointName="cis:TransportationManagerPort"
            serviceName="cis:TransportationManagerService"
            xmlns:cis="http://www.i2.com/cis"
            continuationTimeout="60000">
        <camel-cxf:properties>
            <entry key="dataFormat" value="MESSAGE"/>
            <entry key="username" value="XXX"/>
            <entry key="password" value="XXX"/>
        </camel-cxf:properties>
    </camel-cxf:cxfEndpoint>

【问题讨论】:

    标签: apache-camel cxf


    【解决方案1】:

    您的问题不是很清楚,因为没有骆驼路线,所以我看不出您是在 Camel 内部创建 SOAP 服务,还是从 Camel 作为客户端调用 SOAP 服务。根据您发送的少量信息,您似乎正在创建一个客户端。

    根据骆驼CXF文档

    • continuationTimeout: 该选项用于设置 CXF 延续超时时间,默认情况下可以在 CxfConsumer 中使用 当 CXF 服务器使用 Jetty 或 Servlet 传输时。 (前 Camel 2.14.0,CxfConsumer 只是将延续超时设置为 0,表示继续挂起操作永不超时。)

    请注意,这与 CXF 服务器设置而非客户端设置有关。您正在使用此属性,但我认为这不是您要寻找的。​​p>

    如果您引用Apache CXF Client Settings Documentation 页面,您会在其中找到以下注释:

    • ConnectionTimeout: 指定客户端在它之前尝试建立连接的时间量(以毫秒为单位) 超时。默认值为 30000(30 秒)。 0 指定 客户端将继续无限期地尝试打开连接。
    • ReceiveTimeout: 指定客户端在超时前等待响应的时间量(以毫秒为单位)。这 默认为 60000。0 指定客户端将无限期等待。

    如果您访问 CXF 文档页面,那里有很多示例。

    【讨论】:

    • 非常感谢。 http-conf:conduit 解决了我的问题。
    【解决方案2】:

    以下是如何以编程方式执行此操作:

    HelloWorld hello = (HelloWorld) context.getBean("helloService");
    org.apache.cxf.endpoint.Client client = ClientProxy.getClient(hello);
    HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(5000);
    httpClientPolicy.setAllowChunking(false);
    httpClientPolicy.setReceiveTimeout(5000);
    httpConduit.setClient(httpClientPolicy);
    System.out.println(hello.getHelloWorldAsString("Everyone"));
    

    (我用的是spirng)

    <bean id="helloService"
        class="soap.timeout.demo.client.jaxws.HelloWorld"
        factory-bean="helloServiceFactory" factory-method="create"/>
    <bean id="helloServiceFactory"
        class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
        <property name="serviceClass" value="soap.timeout.demo.client.jaxws.HelloWorld"/>
        <property name="address" value="http://localhost:9999/ws/hello"/>
    </bean>
    

    【讨论】:

      猜你喜欢
      • 2013-11-20
      • 2019-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-11
      相关资源
      最近更新 更多