2015-09-01 24 views
1

我正在使用Soap WS,並且我必須定製每個操作的超時配置。定製實際上是用cxf及其http-conf:conduit來完成的,它不能根據操作級別進行定製。使用Spring的每個操作的自定義超時配置

我的實際配置是:

<bean id="proxyFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"> 
    <property name="serviceClass" value="com.package.PortType" /> 
    <property name="address" ref="URL_WS" /> 
</bean> 

<bean id="URL_WS" class="java.lang.String"> 
    <constructor-arg value="http://serveraddress/Service"/>   
</bean> 

<http-conf:conduit name="http://serveraddress/Service.*"> 
    <http-conf:client ConnectionTimeout="10000" ReceiveTimeout="10000"/> 
</http-conf:conduit> 

有了這個配置,這個WS的所有超時高達10000ms。

如上所述,我想定製它到操作級別,我發現this link並試圖按照這個過程,但我在執行的問題面前,但我只在我的類路徑com.ibm.wsdl.util.xml.QNameUtils哪個對於工廠方法: public static QName newQName(Node paramNode),採用org.w3c.dom.Node的方法。

我試着用這個實現來更改代碼:

<bean id="proxyFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"> 
<property name="delegate"> 
    <jaxws:client serviceClass="com.package.PortType" address="URL_WS" > 
    <jaxws:outInterceptors> 
    <bean class="com.package.CustomTimeoutInterceptor"> 
    <property name="receiveTimeoutByOperationName"> 
     <map key-type="javax.xml.namespace.QName" value-type="java.lang.Long"> 
     <entry value="10"> 
     <key> 
     <bean class="com.ibm.wsdl.util.xml.QNameUtils" factory-method="newQName"> 
      <!-- I don't know what to put here --> 
     </bean> 
     </key> 
     </entry> 
     </map> 
    </property> 
    </bean> 
    </jaxws:outInterceptors> 
    </jaxws:client> 
</property> 
</bean> 

Node的實現我是com.sun.org.apache.xerces.internal.dom.NodeImpl。我不知道哪個NodeImpl'我必須使用的子類以及如何創建它以使其以bean的方式工作,我有點在這些不同的實現和這些不同的dom級別的文檔中丟失自己。 我只是想創建的Node對象子類,這將在此QNameUtils方法工作 或 找到一個不同的方式來定製我的配置

+0

加里 - 看看這個博客條目:http://trimplement.com/custom-operation-timeouts-for-apache-cxf-based-soap-clients/ –

+0

R4J - 這實際上是我在我的問題中提到的鏈接 –

+0

Im blind:(你能給我CXF和Spring版本嗎? –

回答

0

我終於解決了這個問題,這裏是工作的解決方案:

我保留鏈接的CustomTimeoutInterceptor,在this link的幫助下混合瞭解決方案。

我還保留了我的初始配置,我發現javax.xml.namespace.QName有一個工廠方法。我只是說這個部分我的配置:

<!-- Creation of the bean for the interceptor --> 
<bean id="timeoutSetter" class="com.package.CustomTimeoutInterceptor"> 
    <property name="receiveTimeoutByOperationName"> 
    <map key-type="javax.xml.namespace.QName" value-type="java.lang.Long"> 
     <entry value="20000"> 
     <key> 
      <bean class="javax.xml.namespace.QName" factory-method="valueOf"> 
      <constructor-arg value="{http://serveraddress/Service}Operation1" /> 
      </bean> 
     </key> 
     </entry> 
    </map> 
    </property> 
</bean> 

<!-- I had the interceptor the list of outInterceptors --> 
<cxf:bus> 
    <cxf:outInterceptors> 
     <ref bean="timeoutSetter"/> 
    </cxf:outInterceptors> 
</cxf:bus> 
相關問題