title: java.net.SocketTimeoutException: Read timed out WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561)
body: <p>I am getting below exception while calling a SOAP service using WebserviceTemplate. I am using a proxy to connect to the endpoint url.</p>
  
  <p>Below is my XML configuration:</p>
  
  <pre><code>    &lt;bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"&gt;
      &lt;property name="marshaller" ref="jaxb2Marshaller"&gt;&lt;/property&gt;
      &lt;property name="unmarshaller" ref="jaxb2Marshaller"&gt;&lt;/property&gt;
      &lt;property name="defaultUri"&gt;&lt;value&gt;${ws.url}&lt;/value&gt;&lt;/property&gt;
      &lt;property name="interceptors"&gt;  
          &lt;list&gt;  
              &lt;ref local="wsClientSecurityInterceptor"/&gt;  
          &lt;/list&gt;  
      &lt;/property&gt;
      &lt;property name="messageSender" ref="messageSender"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender"&gt;
      &lt;constructor-arg ref="httpClient"&gt;&lt;/constructor-arg&gt;
      &lt;/bean&gt;
  
      &lt;!-- This is my custom class to set the proxy --&gt;
      &lt;bean id="proxyConfig" class="com.somepackage.client.ProxyConfiguration"&gt;
      &lt;property name="proxyHostPlusPort"&gt;&lt;value&gt;${proxy.host}:${proxy.port}&lt;/value&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="httpParams" class="org.apache.commons.httpclient.params.HttpClientParams"&gt;
      &lt;property name="soTimeout" value="120000" /&gt; 
      &lt;/bean&gt;
  
      &lt;bean id="httpClient" class="org.apache.commons.httpclient.HttpClient"&gt;
      &lt;property name="hostConfiguration" ref="proxyConfig" /&gt;
      &lt;property name="params" ref="httpParams" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt;
      &lt;property name="packagesToScan"&gt;
          &lt;list&gt;&lt;value&gt;com.aaa.wsdl&lt;/value&gt;&lt;/list&gt;
      &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="wsClientSecurityInterceptor"  
      class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor"&gt;  
      &lt;property name="securementActions" value="UsernameToken" /&gt;  
      &lt;property name="securementUsername"&gt;&lt;value&gt;${ws.username}&lt;/value&gt;&lt;/property&gt;  
      &lt;property name="securementPassword"&gt;&lt;value&gt;${ws.password}&lt;/value&gt;&lt;/property&gt;
      &lt;property name="securementPasswordType" value="PasswordText" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>Sometimes I am getting below exception while calling the webservice:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>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. </p>
  
  <p>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? </p>
  
  <p>Thanks.</p>