clarkk clarkk -4 years ago 155
PHP Question

SOAP-ERROR: Parsing WSDL: Couldn't load from - but works on WAMP

This works fine on my WAMP server, but doesn't work on the linux master server!?

$client = new SoapClient('', ['trace' => true]);
$result = $client->checkVat([
'countryCode' => 'DK',
'vatNumber' => '47458714'
catch(Exception $e){
echo $e->getMessage();

What am I missing here?! :(

SOAP is enabled


SOAP-ERROR: Parsing WSDL: Couldn't load from '' : failed to load external entity ""/taxation_customs/vies/checkVatService.wsdl"

Call the URL from PHP

Calling the URL from PHP returns error

$wsdl = file_get_contents('');
echo $wsdl;


Warning: file_get_contents( failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable

Call the URL from command line

Calling the URL from the linux command line
HTTP 200
is returned with a XML response


Answer Source

For some versions of php, the SoapClient does not send http user agent information. What php versions do you have on the server vs your local WAMP?

Try to set the user agent explicitly, using a context stream as follows:


    $opts = array(
            'user_agent' => 'PHPSoapClient'

    $context = stream_context_create($opts);
    $client = new SoapClient('',
                             array('stream_context' => $context,
                                   'cache_wsdl' => WSDL_CACHE_NONE));

    $result = $client->checkVat(array(
                                    'countryCode' => 'DK',
                                    'vatNumber' => '47458714'
catch(Exception $e){
    echo $e->getMessage();


It actually seems to be some issues with the web service you are using. The combination of HTTP over IPv6, and missing HTTP User Agent string, seems to give the web service problems.

To verify this, try the following on your linux host:

curl  -A ''  -6

this IPv6 request fails.

curl  -A 'cURL User Agent'  -6

this IPv6 request succeeds.

curl  -A ''  -4
curl  -A 'cURL User Agent'  -4

both these IPv4 request succeeds.

Interesting case :) I guess your linux host resolves to its IPv6 address, and that your version of SoapClient did not add a user agent string by default.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download