title: SOAP client timeouts during function execution
body: <p>I need to use SOAP to retrieve some data from a database. I'm not an experienced PHP programmer, that's why I need some help. The company which provides the webservice (WSDL) gave me login info and links to the svc and wsdl files. They also gave me an example in C# of how to connect:</p>
  
  <pre><code>var proxy = new ChannelFactory&lt;ServiceReferenceWCF.IWebService2&gt;("custom");
              proxy.Credentials.UserName.UserName = login;
              proxy.Credentials.UserName.Password = pass;
              var result = proxy.CreateChannel();
              var logged_in = result.loggedIn();
  </code></pre>
  
  <p>Here's my PHP code:</p>
  
  <pre><code>$wsdl_proto = 'https';
  $wsdl_host = 'their_wsdl_host';
  $wsdl_host_path = 'their_wsdl_path';
  $namespace_proto = 'https';
  $namespace_host = 'their_namespace_host';
  $namespace_path = 'their_namespace_path';
  $location = $namespace_proto.'://'.$namespace_host.$namespace_path;
  $wsdl_url = $wsdl_proto.'://'.$wsdl_host.$wsdl_host_path;
  $connection = new SoapClient($wsdl_url, array('location' =&gt; $location, 'soap_version' =&gt; SOAP_1_1, 'connection_timeout'=&gt; 600,
      'proxy_login' =&gt; "my_login", 'proxy_password' =&gt; "my_password"));
  $functions = $connection-&gt;__getFunctions();
  var_dump($functions);
  $logged_in = $connection-&gt;loggedIn();
  </code></pre>
  
  <p>It hangs during the <code>loggedIn()</code> function call. This function is listed in the $functions variable, so it is valid. I tried some other functions provided by the service - the result is always the same: the script simply freezes. And by that I mean there is no response from the service and PHP waits for the <code>loggedIn()</code> function to finish. After it exceeds the timeout, I get an error: <code>Error Fetching http headers in...</code>
  What am I doing wrong? How can I debug it?</p>
  
  <h1>UPDATE:</h1>
  
  <p>I tried every single thing you guys suggested. But I still didn't manage to solve the problem. I don't use a proxy. You can find the results below:</p>
  
  <p><strong>1.</strong> I installed the SoapUI. After configuring the request for the <code>some_method</code> function (creating a basic Auth with credentials) I received a response: <code>An error occurred when verifying security for the message</code>.
  Ticking the <code>Authenticate pre-emptively</code> option didn't help. I searched for a solution to this error, but I didn't find anything.</p>
  
  <p><strong>2.</strong> I tried almost every imaginable combination of options for the <code>SoapClient</code> class. Here are some of them:</p>
  
  <pre><code>$connection = new SoapClient($wsdl_url, array(
      'login' =&gt; "login",
      'password' =&gt; "pass",
      'trace' =&gt; 1,
  ));
  </code></pre>
  
  <p>The response headers are empty. The request headers:</p>
  
  <pre><code>REQUEST HEADERS:
  POST /file.svc HTTP/1.1
  Host: host
  Connection: Keep-Alive
  User-Agent: PHP-SOAP/5.6.16
  Content-Type: text/xml; charset=utf-8
  SOAPAction: "http://tempuri.org/file/some_method"
  Content-Length: 221
  Authorization: Basic HASH
  
  
  REQUEST:
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"&gt;&lt;SOAP-ENV:Body&gt;&lt;ns1:some_method/&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>Next combination:</p>
  
  <pre><code>$connection = new SoapClient($wsdl,array(
      'login' =&gt; "login",
      'password' =&gt; "pass",
      'trace' =&gt; 1,
      'connection_timeout' =&gt; 500000,
      'cache_wsdl' =&gt; WSDL_CACHE_BOTH,
      'keep_alive' =&gt; false,
  ));
  </code></pre>
  
  <p>The response headers are empty. The request headers are the same, as before.</p>
  
  <p><strong>3.</strong> Using this: </p>
  
  <pre><code>$connection-&gt;__setLocation('https://host.org/file.svc');
  </code></pre>
  
  <p>doesn't help. However when I set the location to the WSDL file instead of the SVC file, I get the following response:</p>
  
  <pre><code>HTTP/1.1 405 Method Not Allowed
  Connection: Keep-Alive
  Content-Length: 1293
  Date: Wed, 23 Dec 2015 14:28:53 GMT
  Content-Type: text/html
  Server: Microsoft-IIS/7.5
  Allow: GET, HEAD, OPTIONS, TRACE
  X-Powered-By: ASP.NET
  </code></pre>
  
  <p>I'm sure that the WSDL service is not slow enough, to exceed the timeout (Ricardo Velhote suggested it).</p>
  
  <p><strong>4.</strong> I've got an XML configuration file provided with the C# example I mentioned earlier:</p>
  
  <pre><code>&lt;client&gt;
      &lt;endpoint address="https://host/file.svc" binding="customBinding" bindingConfiguration="custom" contract="ServiceReference1.file" name="custom" /&gt;
  &lt;/client&gt;
  
  &lt;bindings&gt;
      &lt;customBinding&gt;
          &lt;binding name="custom"&gt;
              &lt;security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"&gt;
                  &lt;localClientSettings detectReplays="false" /&gt;
                  &lt;localServiceSettings detectReplays="false" /&gt;
              &lt;/security&gt;
              &lt;textMessageEncoding messageVersion="Soap11WSAddressing10" /&gt;
              &lt;httpsTransport maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" /&gt;
          &lt;/binding&gt;
      &lt;/customBinding&gt;
  &lt;/bindings&gt;
  </code></pre>
  
  <p>I tried to extend the SoapClient class as suggested <a href="https://stackoverflow.com/questions/6652227/how-to-consume-a-wcf-web-service-that-uses-custom-username-validation-with-a-php">here</a>, but as you can guess it didn't work - the behaviour of the script is still the same.</p>