用spring替换cxf参数(动态)

时间:2013-06-07 13:57:52

标签: spring cxf

我关注cxf.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jaxws="http://cxf.apache.org/jaxws"
      xmlns:http="http://cxf.apache.org/transports/http/configuration"
      xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
              http://cxf.apache.org/transports/http/configuration
      http://cxf.apache.org/schemas/configuration/http-conf.xsd">
    <http:conduit name="http://localhost:8080/mockInterfaceSoap">
        <http:client ReceiveTimeout="5000" />
    </http:conduit>
</beans>

有没有办法用spring替换硬编码的ReceiveTimeout参数值?

编辑:
我想在运行时动态更改它。变化非常罕见,因此应用可以更改现有端点或创建新端点。

2 个答案:

答案 0 :(得分:0)

也许org.apache.cxf.jaxrs.client.WebClient有帮助。我前段时间发现了对它的引用并在以下示例中使用过它:

String endpointAddress = "*";
WebClient client = WebClient.create(endpointAddress);
HTTPConduit httpConduit = WebClient.getConfig(client).getHttpConduit();
httpConduit.setTlsClientParameters(new TLSClientParameters());
httpConduit.getTlsClientParameters().setUseHttpsURLConnectionDefaultHostnameVerifier(true);
httpConduit.getTlsClientParameters().setUseHttpsURLConnectionDefaultSslSocketFactory(true);
return httpConduit;

答案 1 :(得分:0)

您可以按以下方式使用它。

<jaxrs-client:client id="clientId" serviceName="clientServiceName"
                 address="${urlService}" >
</<jaxrs-client:client>

<http-conf:conduit  name="*clientServiceName*.http-conduit" >
     <http-conf:client ReceiveTimeout="1"/>
</http-conf:conduit>