Php – SoapClient LibXMLError: failed to load external entity, SOAP-ERROR: Parsing WSDL: Couldn’t load


I am trying to establish a SOAP connection using the following PHP code, and it's failing at the point of the SoapClient construct:

// Need to declare these settings here because our php.ini has alternate
// settings due to global purposes for other PHP scripts
ini_set("soap.wsdl_cache_enabled", "0");
ini_set("soap.wsdl_cache", "0");

// FedEx web services URL, note the HTTPS
$path_to_wsdl = '';

$soap_args = array(

try {
    $client = new SoapClient($path_to_wsdl,$soap_args);
} catch (SoapFault $e) {
    echo "<BR><BR>";

This outputs:

object(LibXMLError)#1 (6) {
    ["level"]=> int(1)
    ["code"]=> int(1549)
    ["column"]=> int(0)
    ["message"]=> string(71) "failed to load external entity "" "
    ["file"]=> string(0) ""
    ["line"]=> int(0)

object(SoapFault)#2 (9) {
    ["message":protected]=> string(158) "SOAP-ERROR: Parsing WSDL: Couldn't load from '' : failed to load external entity "" "
    ["string":"Exception":private]=> string(0) ""
    ["code":protected]=> int(0)
    ["file":protected]=> string(53) "/mnt/array/bell-enterprise/bell/fedex_shipservice.php"
    ["line":protected]=> int(34)
    ["trace":"Exception":private]=> array(1) {
        [0]=> array(6) {
            ["file"]=> string(53) "/mnt/array/bell-enterprise/bell/fedex_shipservice.php"
            ["line"]=> int(34)
            ["function"]=> string(10) "SoapClient"
            ["class"]=> string(10) "SoapClient"
            ["type"]=> string(2) "->"
            ["args"]=> array(2) {
                [0]=> string(37) ""
                [1]=> array(4) {
                    ["exceptions"]=> bool(true)
                    ["soap_version"]=> int(1)
                    ["cache_wsdl"]=> int(0)
                    ["trace"]=> int(1)
    ["previous":"Exception":private]=> NULL
    ["faultstring"]=> string(158) "SOAP-ERROR: Parsing WSDL: Couldn't load from '' : failed to load external entity "" "
    ["faultcode"]=> string(4) "WSDL"

Best Solution

After 6 hours of headache, the ONLY solution is to download the WSDL files. and

It will always throw an error 500, because this is not the wsdl.

Once you download the wsdls from Technical Resources -> FedEx WebServices For Shipping -> GetStarted (click on "Rate Services" and then "Download WSDL or XML"), in your script you will need to load your locally stored WSDL and everything will work like a charm.

$this->_soapClient = new SoapClient("RateService_v13.wsdl", array('exceptions'=>true, 'trace' => true));

Have fun!

Related Question