Soap PHP Fault Parsing Wsdl: Failed to Load External Entity

PHP SoapClient fails with - Failed to load external entity

After spending hours researching and trying to figure out the problem I found a 2 years old post that somehow served my purpose.

Unfortunately I can't mark this as duplicate so I'll just link it here: SOAP error parsing wsl couldn't load from but works on wamp

I couldn't find this question because Google didn't tag it as using the Europa services.

Either way, my problem was that I needed to specify my user agent explicitly because Europa web services are too outdated and can't resolve IPv6 requests, only IPv4. Like so:

$opts = array(
'http'=>array(
'user_agent' => 'PHPSoapClient'
)
);

$context = stream_context_create($opts);
$client = new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl',
array('stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_NONE));

$result = $client->checkVat(array(
'countryCode' => 'DK',
'vatNumber' => '47458714'
));

The example uses the CheckVAT SOAP function but it works just as well for the CheckTIN function.

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

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!



Related Topics



Leave a reply



Submit