title: PHP SoapClient Constructor extremely slow
body: <p>I'm trying to do some tests on a SOAP API and am experiencing extremely slow execution times. I've done some digging and found that it's the SoapClient constructor that takes forever to execute. I also tried using a proxy for it to see if it's the http query resulting from it, but this query is executed relatively fast.. it's after the query that it lingers for about 30 seconds.</p>
  
  <p>Here's a kcachegrind screenshot for reference:</p>
  
  <p><img src="https://i.stack.imgur.com/NJlKJ.png" alt="kcachegrind"></p>
  
  <p>And here's the WSDL query in Charles Proxy:</p>
  
  <p><img src="https://i.stack.imgur.com/UlzsF.png" alt="charles proxy"></p>
  
  <p>This same problem has also been reported a couple of months ago here:</p>
  
  <p><a href="https://stackoverflow.com/questions/5944067/php-soapclient-constructor-is-very-slow-takes-3-minutes">PHP: SoapClient constructor is very slow (takes 3 minutes)</a></p>
  
  <p>But he did not get an answer.</p>
  
  <p>Any suggestions would be much appreciated.</p>
  
  <p>Edit:</p>
  
  <p>The code portion where the SoapClient is initiated (this is part of the NetSuite PHP toolkit)</p>
  
  <pre><code>        $this-&gt;client = new SoapClient( $host . "/wsdl/v" . $endpoint . "_0/netsuite.wsdl",
  
                                      array(  "location"              =&gt; $host . "/services/NetSuitePort_" . $endpoint,
  
                                              "trace"                 =&gt; 1,
  
                                              "connection_timeout"    =&gt; 5,
  
                                              "typemap"               =&gt; $typemap,
  
                                              "user_agent"            =&gt; "PHP-SOAP/" . phpversion() . " + NetSuite PHP Toolkit " . $version
  
                                      )
  
      );
  </code></pre>