
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:
-
Ensure the WSDL file is available and accessible: Verify that the WSDL file specified in the client constructor URL exists at the specified path and is accessible by the SOAP client.
-
Disable SSL verification (Security Concern): If using PHP 5.6.5 or later and establishing a SOAP 1.2 connection, adding SSL parameters to the client constructor may resolve the issue:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <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>
|
Copy after login
Note: Disabling SSL verification is a security risk and should not be used in production environments.
-
Verify the WSDL file format: Ensure that the WSDL file is a valid XML document that conforms to the WSDL specification.
-
Check network connectivity: Verify that the SOAP client has network access to the server hosting the WSDL file.
-
Consider using WSDL file caching: Enabling WSDL file caching in PHP can prevent repeated downloads and improve performance:
1 2 | <code class = "php" > ini_set ( "soap.wsdl_cache_enabled" , "1" );
ini_set ( "soap.wsdl_cache_ttl" , "86400" );
|
Copy after login
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!