如何在启动时处理Spring Webservice连接错误?

B. *_*oto 5 java spring web-services

我在Spring中使用JaxWsPortProxyFactoryBean来连接SOAP Web服务.问题是,如果在Spring启动的那一刻,webservice已关闭(由于网络问题).它将导致异常并停止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>
Run Code Online (Sandbox Code Playgroud)

谢谢,

nde*_*rge 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>
Run Code Online (Sandbox Code Playgroud)