2012-04-06 27 views
5

我在Spring中使用JaxWsPortProxyFactoryBean來連接SOAP web服務。問題是如果在Spring啓動的時候web服務出現故障(由於網絡問題)。它會導致異常並停止Spring初始化。我不想要這種行爲,應用程序不需要停止,只是因爲Web服務連接失敗。如何在啓動時處理Spring Webservice連接錯誤?

有什麼更好/正確的方式使用Spring來處理這個問題? 這是我目前的xml上下文。

<bean id="beanWebServiceSOAP" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean" lazy-init="true"> 
    <property name="serviceInterface" value="com.company.bean.BeanWebServiceSoap" /> 
    <property name="wsdlDocumentUrl" value="${bean.wsdldocumenturl}" /> 
    <property name="namespaceUri" value="${bean.namespaceuri}" /> 
    <property name="serviceName" value="BeanWebService" /> 
    <property name="portName" value="BeanWebServiceSoap" /> 
</bean> 

感謝,

+0

你能證明你的Spring配置? – 2012-04-06 08:19:50

+0

是的,我要把它放在問題 – 2012-04-06 08:23:27

回答

7

也許由酒店 'lookupServiceOnStartup' 設置爲false:

<bean id="beanWebServiceSOAP" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean" lazy-init="true"> 
    <property name="serviceInterface" value="com.company.bean.BeanWebServiceSoap" /> 
    <property name="wsdlDocumentUrl" value="${bean.wsdldocumenturl}" /> 
    <property name="namespaceUri" value="${bean.namespaceuri}" /> 
    <property name="serviceName" value="BeanWebService" /> 
    <property name="portName" value="BeanWebServiceSoap" /> 
    <property name="lookupServiceOnStartup" value="false" /> 
</bean> 
+0

好吧,我要去嘗試它,但我必須確保如果連接已建立。該應用程序可以訪問Web服務 – 2012-04-06 08:36:59

-1

你爲什麼不使用RestOperations或RestTemplate?

+0

是SOAP Webservice,我要精確的在我的問題 – 2012-04-06 08:17:44