-1

I am getting below exception while calling a SOAP service using WebserviceTemplate. I am using a proxy to connect to the endpoint url.

Below is my XML configuration:

    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    <property name="marshaller" ref="jaxb2Marshaller"></property>
    <property name="unmarshaller" ref="jaxb2Marshaller"></property>
    <property name="defaultUri"><value>${ws.url}</value></property>
    <property name="interceptors">  
        <list>  
            <ref local="wsClientSecurityInterceptor"/>  
        </list>  
    </property>
    <property name="messageSender" ref="messageSender"></property>
    </bean>

    <bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
    <constructor-arg ref="httpClient"></constructor-arg>
    </bean>

    <!-- This is my custom class to set the proxy -->
    <bean id="proxyConfig" class="com.somepackage.client.ProxyConfiguration">
    <property name="proxyHostPlusPort"><value>${proxy.host}:${proxy.port}</value></property>
    </bean>

    <bean id="httpParams" class="org.apache.commons.httpclient.params.HttpClientParams">
    <property name="soTimeout" value="120000" /> 
    </bean>

    <bean id="httpClient" class="org.apache.commons.httpclient.HttpClient">
    <property name="hostConfiguration" ref="proxyConfig" />
    <property name="params" ref="httpParams" />
    </bean>

    <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    <property name="packagesToScan">
        <list><value>com.aaa.wsdl</value></list>
    </property>
    </bean>

    <bean id="wsClientSecurityInterceptor"  
    class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">  
    <property name="securementActions" value="UsernameToken" />  
    <property name="securementUsername"><value>${ws.username}</value></property>  
    <property name="securementPassword"><value>${ws.password}</value></property>
    <property name="securementPasswordType" value="PasswordText" />
    </bean>

Sometimes I am getting below exception while calling the webservice:

org.springframework.ws.client.WebServiceIOException: I/O error: Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)

Even though I've set the soTimeout, I am getting this issue. What i suspect is, issue comes when proxy is down for more than 2 minutes.

Can someone guide me how can I get rid of this issue? Is setting soTimeout alone is enough or we need to set some more params?

Thanks.

rupesh
  • 333
  • 6
  • 18
  • You can't get rid of the proxy being down for more than two minutes, other than by using a more reliable proxy. Unclear what you're asking. – user207421 Nov 02 '17 at 02:51
  • How can I confirm whether it was really an issue with proxy or the actual endpoint system? – rupesh Nov 02 '17 at 05:49

1 Answers1

0

You cannot ignore lower level (hardware/network) errors, this being said you can track them and respond accordingly by adding some intelligence in your application.

For example by doing a couple of additional attempts, etc. In order to have a more robust application.

After several try you can send back a message to the user saying that there is a network issue and that is request can not be fulfilled right now and use a logger to track it.

If this is really frequent, an action should be taken at the infra level.

Use:

-> try/catch, throw exception
Allan
  • 11,170
  • 3
  • 22
  • 43