title: PHP SoapClient using WCF service hosted in Windows application on Windows 2008 Server
body: <p>This question relates to the requirement to utilize a WCF service hosted in a Windows application on Windows 2008 Server, from PHP scripts which are hosted in IIS 7 on the same server, and from other applications hosted elsewhere.</p>
  
  <p>The application has been developed and tested thoroughly on a Windows 7 machine using Visual Studio 2010, .NET Framework 4, IIS 7, and various versions of PHP.</p>
  
  <p>On the Windows 7 machine, netsh was used as follows.</p>
  
  <pre><code>netsh http add urlacl url=http://localhost:8000/WCFService/ user=machinename\user
  </code></pre>
  
  <p>Various other ports were also successfully added and used during testing.</p>
  
  <p>When the application was copied to the Windows 2008 Server, the essential parts of the application were successfully tested.</p>
  
  <p>The same netsh command was used on Windows 2008 Server, yet localhost was replaced with the server IP and machinename with domain as follows:</p>
  
  <pre><code>netsh http add urlacl url=http://serveripaddress:8000/WCFService/ user=domain\user
  </code></pre>
  
  <p>During attempts to get the PHP SoapClient working, various user="..." options were attempted, including "everyone".</p>
  
  <p>The initial PHP SoapClient script is as follows:</p>
  
  <pre><code>try {
    $client = new SoapClient("http://serveripaddress:8000/WCFService/?wsdl");
  } catch (Exception $e) {
    echo $e-&gt;getMessage(), "\n"; 
    exit();
  }
  </code></pre>
  
  <p>During initial testing, the following errors were encountered:</p>
  
  <blockquote>
    <p>Warning:
    SoapClient::SoapClient(http://serveripaddress:8000/WCFService/?wsdl)
    [soapclient.soapclient]: failed to open stream: HTTP request failed!
    in C:\inetpub\wwwroot\Sites\www.myurl.com\WCF-Test.php on line 7</p>
    
    <p>Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O
    warning : failed to load external entity
    "http://serveripaddress:8000/WCFService/?wsdl" in
    C:\inetpub\wwwroot\Sites\www.myurl.com\WCF-Test.php on line 7</p>
    
    <p>SOAP-ERROR: Parsing WSDL: Couldn't load from
    'http://serveripaddress:8000/WCFService/?wsdl' : failed to load
    external entity "http://serveripaddress:8000/WCFService/?wsdl"</p>
  </blockquote>
  
  <p>After some fiddling around the error reduced to the following:</p>
  
  <blockquote>
    <p>SOAP-ERROR: Parsing WSDL: Couldn't load from
    'http://serveripaddress:8000/WCFService/?wsdl' : failed to load
    external entity "http://serveripaddress:8000/WCFService/?wsdl"</p>
  </blockquote>
  
  <p>I then extracted the wsdl into a file and used the following PHP script:</p>
  
  <pre><code>try {
    $client = new SoapClient("wsdl\wcf-wsdl.wsdl");
  } catch (Exception $e) {
    echo $e-&gt;getMessage(), "\n"; 
    exit();
  }
  </code></pre>
  
  <p>The error then changed slightly to the following:</p>
  
  <blockquote>
    <p>SOAP-ERROR: Parsing Schema: can't import schema from
    'http://serveripaddress:8000/WCFService/?xsd=xsd0'</p>
  </blockquote>
  
  <p>I am of the opinion that the issue at hand relates to the "visibility" of the service, to the client, and possibly permissions.</p>
  
  <p>After reading dozens of posts, I still have not been able to find a solution to this issue.</p>
  
  <p>Any assistance will be greatly appreciated.</p>
  
  <p>Many thanks in advance.</p>