Home > Article > Backend Development > Why does my PHP SOAP connection fail with \"SOAP-ERROR: Parsing WSDL: Couldn\'t load from [URL] : failed to load external entity [URL]\"?
SOAP PHP Fault Parsing WSDL: Failed to Load External Entity
When attempting to establish a SOAP connection using PHP, you may encounter the error "SOAP-ERROR: Parsing WSDL: Couldn't load from [URL] : failed to load external entity [URL]". This error indicates that the SOAP client is unable to access the WSDL file referenced in the client's constructor.
Troubleshooting Steps:
<code class="php">$opts = array( 'ssl' => array( 'ciphers' => 'RC4-SHA', 'verify_peer' => false, 'verify_peer_name' => false ) ); $params = array( 'encoding' => 'UTF-8', 'verifypeer' => false, 'verifyhost' => false, 'soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 1, 'connection_timeout' => 180, 'stream_context' => stream_context_create($opts) ); $wsdlUrl = $url . '?WSDL'; $oSoapClient = new SoapClient($wsdlUrl, $params);</code>
Note: Disabling SSL verification is a security risk and should not be used in production environments.
<code class="php">ini_set("soap.wsdl_cache_enabled", "1"); ini_set("soap.wsdl_cache_ttl", "86400"); // 24 hours</code>
The above is the detailed content of Why does my PHP SOAP connection fail with \"SOAP-ERROR: Parsing WSDL: Couldn\'t load from [URL] : failed to load external entity [URL]\"?. For more information, please follow other related articles on the PHP Chinese website!