title: php soapclient wsdl SOAP-ERROR: Parsing WSDL: Couldn't load from
body: <p>I have googled and looked here in stackoverflow but I have not found a solution to my specific problem. I keep getting the error </p>
  
  <pre><code> SOAP-ERROR: Parsing WSDL: Couldnt load from "https://sampleurl.com/MerchantQueryService.asmx?WSDL" : failed to load external entity "https://sampleurl.com/MerchantQueryService.asmx?WSDL"
  </code></pre>
  
  <p>I am trying to use a SOAP API with a URL like </p>
  
  <pre><code>https://sampleurl.com/MerchantQueryService.asmx?WSDL 
  </code></pre>
  
  <p>I am running MAMP on my localhost and using godaddy shared hosting, I have tried on both with the wsdl file can be found here </p>
  
  <pre><code>http://clemdemo.com/test.wsdl
  </code></pre>
  
  <p>In PHP I use the code below</p>
  
  <pre><code>error_reporting(-1);
  ini_set('display_errors', 'On');
  ini_set('soap.wsdl_cache_enabled', 0);
  
  echo "&lt;pre&gt;";
  
  try {
  
  $url     = "https://sampleurl.com/MerchantQueryService.asmx?WSDL ";
  $headers = [
      'Host: sampleurl.com',
      'Connection: Keep-Alive',
      'User-Agent: PHP-SOAP/5.3.29',
      'Content-Type: text/xml; charset=utf-8',
      'SOAPAction: "RequestTransaction"',
      'Content-Length: 409'];
  
  $rq = [
  "userName" =&gt; "username_here",
  "passWord" =&gt; "password_here",
  "referenceId" =&gt; "3455566694",
  "msisdn" =&gt; "346774313"];
  
  
  try {
  
  $cient = new SoapClient($url,
      [
      'soap_version' =&gt; SOAP_1_2,
      'exceptions' =&gt; 1,
      'cache_wsdl' =&gt; WSDL_CACHE_NONE,
      'trace' =&gt; 1,
      'stream_context' =&gt; stream_context_create(array('http' =&gt; array('header' =&gt; $headers)))
  ]);
  
  print_r($cient);
  } catch (SoapFault $e) {
      echo "\nFault Code: ".$e-&gt;faultcode;
      echo "\nFault String: ".$e-&gt;faultstring;
  }
  </code></pre>
  
  <p>On my MAMP localhost i have SOAP,openssl and curl.</p>
  
  <p>ALSO, I tried using (sending request) to the API with an online WSDL <a href="http://wsdlbrowser.com" rel="noreferrer">http://wsdlbrowser.com</a> it WORKS but on code using PHP it fails</p>