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

29,935

Solution 1

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

https://wsbeta.fedex.com/web-services and https://ws.fedex.com/web-services

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!

Solution 2

That url is NOT the path to a WSDL , but the url the SOAP requests should be going to. Never worked with the guys, but I gather you can get a wsdl file somewhere and store it locally, and you can alter the endpoint in that wsdl to the wsbeta one. I cannot find the wsdl's and the fedex site doesn't allow me to go further in their dev technical resources without signing up, so I'll leave it at that: you wsdl is somewhere else, the url you have is just the location of a particular service.

Share:
29,935
David
Author by

David

Updated on August 04, 2020

Comments

  • David
    David almost 4 years

    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");
    ini_set("display_errors","On");
    ini_set("track_errors","On");
    
    // FedEx web services URL, note the HTTPS
    $path_to_wsdl = 'https://wsbeta.fedex.com/web-services';
    
    $soap_args = array(
        'exceptions'=>true,
        'cache_wsdl'=>WSDL_CACHE_NONE,
        'trace'=>1)
    ;
    
    try {
        $client = new SoapClient($path_to_wsdl,$soap_args);
    } catch (SoapFault $e) {
        var_dump(libxml_get_last_error());
        echo "<BR><BR>";
        var_dump($e);
    }
    

    This outputs:

    object(LibXMLError)#1 (6) {
        ["level"]=> int(1)
        ["code"]=> int(1549)
        ["column"]=> int(0)
        ["message"]=> string(71) "failed to load external entity "https://wsbeta.fedex.com/web-services" "
        ["file"]=> string(0) ""
        ["line"]=> int(0)
    }
    
    object(SoapFault)#2 (9) {
        ["message":protected]=> string(158) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://wsbeta.fedex.com/web-services' : failed to load external entity "https://wsbeta.fedex.com/web-services" "
        ["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) "https://wsbeta.fedex.com/web-services"
                    [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 'https://wsbeta.fedex.com/web-services' : failed to load external entity "https://wsbeta.fedex.com/web-services" "
        ["faultcode"]=> string(4) "WSDL"
    }
    
  • David
    David about 12 years
    I already was doing so, and I removed that option because it wasn't making a difference. The cert had no impact whatsoever on the output.
  • alganet
    alganet about 12 years
    Is allow_url_fopen enabled on php.ini settings?
  • David
    David about 12 years
    Yes, allow_url_fopen is enabled
  • David
    David about 12 years
    alganet, BTW - I've seen conflicting answers about the 'local_cert': should it be the path to the file, or a "file_get_contents($path)" to provide a string with the contents of the cert? (Neither has worked for me but I'd appreciate your feedback anyway, for my future reference.)
  • David
    David over 10 years
    Thanks Justin. This is what I eventually found out to be true myself, and as I read back over this original post, I never closed it out with the correct answer noted. Yours is indeed the correct solution, which I find after hours of beating my head against the wall as well. The FedEx documentation is horribly lacking in this regard.
  • David
    David over 10 years
    Thanks Wrikken. As noted on Justin's answer, I checked his because it was more precise and complete as it related to my problem, but your answer is also correct.