title: Unable to sendViaPost to url Read timed out
body: <p>I'm working on java web service clients nowadays. But I'm faced a big problem for me. My problem is that:
  I'm generated web service client with Eclipse via its web service client generator. It generates web service through Apache Axis2. My web service java code is generated and I use it successfully with a wsdl which <strong>isn't require</strong> security header. But I cannot use it with a web service which needs a security header.</p>
  
  <p>I try to get my request with fiddler2. but fiddler not capture any packet related my request. but when I print my created request and use this xml with soapui, operation is successfully perform. </p>
  
  <p>increasing timeout setting not work. </p>
  
  <p>what can I do?</p>
  
  <p>my xml and java error is given below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
     &lt;soapenv:Header&gt;
        &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1"&gt;
           &lt;wsse:UsernameToken&gt;
              &lt;wsse:Username&gt;username&lt;/wsse:Username&gt;
              &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;password&lt;/wsse:Password&gt;
           &lt;/wsse:UsernameToken&gt;
        &lt;/wsse:Security&gt;
        &lt;wsse:ReplyTo xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
           &lt;wsse:Address&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/wsse:Address&gt;
        &lt;/wsse:ReplyTo&gt;
        &lt;wsse:MessageID xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;urn:uuid:123&lt;/wsse:MessageID&gt;
        &lt;wsse:Action xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1"&gt;http://www.saglik.gov.tr/KPS/2011/KPSServices/TcKimlikNoIleKisiSorgula&lt;/wsse:Action&gt;
     &lt;/soapenv:Header&gt;
     &lt;soapenv:Body&gt;
        &lt;ns1:TcKimlikNoIleKisiSorgula xmlns:ns1="http://www.saglik.gov.tr/KPS/2011"&gt;
           &lt;ns1:tcNo&gt;155***58&lt;/ns1:tcNo&gt;
        &lt;/ns1:TcKimlikNoIleKisiSorgula&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>and error message:</p>
  
  <pre><code>[INFO] Unable to sendViaPost to url[https://kps.saglik.gov.tr/services/kpsservices.svc]
  java.net.SocketTimeoutException: Read timed out
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:150)
      at java.net.SocketInputStream.read(SocketInputStream.java:121)
      at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
      at sun.security.ssl.InputRecord.read(InputRecord.java:480)
      at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
      at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
      at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
      at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
      at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
      at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
      at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
      at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
      at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
      at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
      at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
      at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
      at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
      at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
      at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
      at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
      at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
      at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
      at org.apache.axis2.description.OutInAxisOperationClient$NonBlockingInvocationWorker.run(OutInAxisOperation.java:446)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:724)
  </code></pre>
  
  <p>and my code is below</p>
  
  <pre><code>public static void main(String[] args){
  ServiceStub stub = new ServiceStub();
      ServiceClient client = stub._getServiceClient();
      client.addHeader(createSecurityHeader("username", "password"));
  
      OMNamespaceImpl wsseNS = new OMNamespaceImpl(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
      OMFactory factory = new SOAP11Factory();
      OMElementImpl replyToElement;
      OMElementImpl addressElement;
      OMElementImpl messageIDElement;       OMElementImpl actionElement;
  
      replyToElement = new OMElementImpl("ReplyTo", wsseNS, factory);
  
      addressElement = new OMElementImpl("Address", wsseNS, replyToElement, factory);
      addressElement.setText("http://www.w3.org/2005/08/addressing/anonymous");
  
      client.addHeader(replyToElement);
      messageIDElement = new OMElementImpl("MessageID", wsseNS, factory);
      messageIDElement.setText("urn:uuid:"+123);
      client.addHeader(messageIDElement);
      actionElement = new OMElementImpl("Action", wsseNS, factory);
      actionElement.addAttribute("mustUnderstand", "1", null);
      actionElement.setText("http://www.saglik.gov.tr/KPS/2011/KPSServices/TcKimlikNoIleKisiSorgula");
      client.addHeader(actionElement);
      Options options = client.getOptions();
  
      options.setProperty(HTTPConstants.CHUNKED, "false");
      options.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_11);
  
      TcKimlikNoIleKisiSorgula kisi = new TcKimlikNoIleKisiSorgula();
      kisi.setTcNo(155*****58L);//require an long
      stub.starttcKimlikNoIleKisiSorgula(kisi, callback);
  }
  
  
  public static OMElement createSecurityHeader(String username, String password)
  {
          OMNamespaceImpl wsseNS = new OMNamespaceImpl(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
          OMFactory factory = new SOAP11Factory();
          OMElementImpl securityHeader;
          OMElementImpl usernameTokenElement;
          OMElementImpl usernameElement;
          OMElementImpl passwordElement;
  
          // create the Security header block
          securityHeader = new OMElementImpl("Security", wsseNS, factory);
          securityHeader.addAttribute("mustUnderstand", "1", null);
  
          // nest the UsernameToken in the Security header
          usernameTokenElement = new OMElementImpl(WSConstants.USERNAME_TOKEN_LN, wsseNS, securityHeader, factory);
  
          // nest the Username and Password elements
          usernameElement = new OMElementImpl(WSConstants.USERNAME_LN, wsseNS, usernameTokenElement, factory);
          usernameElement.setText(username);
  
          passwordElement = new OMElementImpl(WSConstants.PASSWORD_LN, wsseNS, usernameTokenElement, factory);
          passwordElement.setText(password);
          passwordElement.addAttribute(WSConstants.PASSWORD_TYPE_ATTR,
          WSConstants.PASSWORD_TEXT, null);
  
          return securityHeader;
      }
  </code></pre>