Asked  2 Years ago    Answers:  5   Viewed   543 times

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




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:

try {
    $opts = array(
        'http' => array(
            'user_agent' => 'PHPSoapClient'
    $context = stream_context_create($opts);

    $wsdlUrl = '';
    $soapClientOptions = array(
        'stream_context' => $context,
        'cache_wsdl' => WSDL_CACHE_NONE

    $client = new SoapClient($wsdlUrl, $soapClientOptions);

    $checkVatParameters = array(
        'countryCode' => 'DK',
        'vatNumber' => '47458714'

    $result = $client->checkVat($checkVatParameters);
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.

Wednesday, October 12, 2022

You're probably right about the header being the cause, or at least part of it. I am not currently within easy reach of a soap server, but I hope the below can at least give some pointers.

There are two possibilities here: either the header should be included as a SoapHeader object, or you need to build your parameters array differently. I'll list both versions.

Either way, you can probably skip the __soapCall() method and use the magic method instead, since you appear to be using wsdl.

Parameters version (try this first)

If you're lucky, you just need to reformat the body in order to suit the given schema. It honestly kinda looks like that. Something like this:

$params = array(
    'request' => array(
        'Header' => array(
            'Token' => 'hello'
        'Parameters' => array(
            'DeviceID' => 12345,
            'SourceScreen' => 12345,
            'Language' => 'E',
            'LocalDateTime' => '2015-05-20T11:59:29.910Z',  
            'TicketID' => 12345,
            'PayScreenAttributeID' => 12345,
            'InputValue' => '123456789',
            'PaymentAmount' => 0,
            'POSReceiptCustomer' => '?',
            'POSReceiptMerchant' => '?'

$wsdl_path = "";
$soapClient = new SoapClient($wsdl_path, array('trace' => 1));
$response = $soapClient->ProcessTransaction($params);

SoapHeader version

What you need to do if you actually do need a proper header is to create an header object and attach it to the client you've instantiated. Then, you can call the endpoint.

In order to do so you need to know the namespace, which should be called targetNameSpace in your schema. You'll also need to know the name, which you can see in e.g. SoapUI.

Finally, it should be enough to just supply the parameters straight away - no need to put them in a single-element array. So you end up with something like the below. With any luck, that may at least put you in the right direction. :)

// instantiate soap client
$wsdl_path = "";
$soapClient = new SoapClient($wsdl_path, array('trace' => 1));

// create and attach a header
$header = new SoapHeader($namespace, $name, array('Token' => 'hello'));

// call the endpoint
$response = $soapClient->ProcessTransaction($inputParams);
var_dump($response); // hopefully you get something back...
Thursday, December 8, 2022

The WSDL you are trying to make a client for is an abstract WSDL document. An abstract WSDL could be used for analyzing purposes but it does not contain all the necessary information to call a service.

The technical information about calling a service for example via SOAP is stored in the binding element of a WSDL. In case of your WSDL there is no binding information available.

Friday, August 19, 2022

Couldn't find any straightforward way to create a header with params as attributes of one node. In the end this works, though not very pretty:

$client = new SoapClient(NULL, 
                         array('location' => $loc, 'uri' => $ns, 
                               'soap_version' => SOAP_1_2, 
                               'style' => SOAP_DOCUMENT));
$headerVar = new SoapVar('<ns1:RequestParams Size="Large" Color="Blue" Brand="xyz"/>',
$header = new SoapHeader($ns, 'RequestParams', $headerVar);
$result = $client->__soapCall('SomeFunc', array(...));

Thanks to Feroz for suggesting an answer, whitch btw works if you are sending parameters in __soapCall, just didn't work when creating a header.

Thanks also to cb for the solution:

Thursday, September 22, 2022

The trouble was solved. In fact when I had so errors using WAMP(orange icon) I decided to set it up again.

So I installed the newest version of WAMP but there was no the same php.ini as I used previously and in fact the trouble was that on the php.ini I had to make active the line ;extension=php_openssl.dll

so I just removed the ;character and this line has become like extension=php_openssl.dll

Now it works fine.

Wednesday, August 24, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages