Viewed   559 times

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

try{
    $client = new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', ['trace' => true]);
    $result = $client->checkVat([
        'countryCode' => 'DK',
        'vatNumber' => '47458714'
    ]);
    print_r($result);
}
catch(Exception $e){
    echo $e->getMessage();
}

What am I missing here?! :(

SOAP is enabled

Error

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

Call the URL from PHP

Calling the URL from PHP returns error

$wsdl = file_get_contents('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl');
echo $wsdl;

Error

Warning:  file_get_contents(http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl): 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

curl http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

 Answers

2

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 = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
    $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);
    print_r($result);
}
catch(Exception $e) {
    echo $e->getMessage();
}

Edit

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 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

this IPv6 request fails.

curl  -A 'cURL User Agent'  -6 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

this IPv6 request succeeds.

curl  -A ''  -4 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
curl  -A 'cURL User Agent'  -4 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

both these IPv4 request succeeds.

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

Wednesday, October 12, 2022
5

Some gochas that I only found through trial and error are some configuration issues, on the server that is running the reporting server service, make sure that in your file rsreportserver.config has been modified to allow for basic authentication. By default, if I'm understanding it correctly, it wants a more trustworthy connection type, but the sdk needs you to allow simple name and passwords to be passed. This means that needs to be added to your authentication methods in the configuration.

so for example,

In C:Program FilesMicrosoft SQL ServerMSRS11.1Reporting ServicesReportServerrsreportserver.config (Different for server and version, but you get the idea.)

<Authentication>
    <AuthenticationTypes>
        <RSWindowsNTLM/>
        <RSWindowsBasic/> ##you need to add this one##
    </AuthenticationTypes>
    <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
</Authentication>

IIRC you will have to restart the service for this to take effect.

Also, if you are attempting to RenderAs, some of the template files used to pop the headers have space in them towards the bottom that will prevent you from rendering as Excel, PDF, ect unless that has been fixed since I worked on it.

I'm looking through the code you provided, I may be reading it wrong, but it looks like you are trying to explicitly define the report you're after in the execution url. If that is in fact what you are doing, I believe the fix would be to only define the report base you are connecting to so for your example the url should be http://172.16.4.63/ReportServer/. After that connection is made, you would use the LoadReport2 function to specify which report you need.

Lastly, Where you have the name of the report, it looks like you have a subdirectory called testfolder? if that is still the case, you would need your report name to be "/TestFolder/testClaimHdr" in the call to LoadReport2.

Hope any of that helps.

Wednesday, August 10, 2022
 
4

Have you tried SoapClient which is already built into PHP?

There is one tutorial: PHP - Soap Client calling .NET Web service

Here is another one, even though it was created for zend developers it should work fine.

Monday, September 5, 2022
 
1

Don't run the XML through SOAPVar, and take advantage of the WSDL option of your web service if you can:

<?php

$client = new SOAPClient(
    'http://webserviceurl.asmx?WSDL',
    array(
        'location' => 'http://webserviceurl.asmx',
        'trace' => 1,
        'style' => SOAP_RPC,
        'use' => SOAP_ENCODED,
    )
);

$request = '<item xmlns="rmsItem">
      <columns>
        <column>description</column>
        <column>department</column>
        <column>brand</column>
        <column>lastsold</column>
        <column>lastupdated</column>
        <column>quantityonhand</column>
        <column>weight</column>
      </columns>
      <filters>
        <filter>
          <filterColumn>quantityonhand</filterColumn>
          <operator>greaterthan</operator>
          <filterValue>20</filterValue>
        </filter>
        <filter>
          <filterColumn>lastsold</filterColumn>
          <operator>greaterthan</operator>
          <filterValue>01-01-2005</filterValue>
        </filter>
      </filters>
      <sortColumns>
        <sortColumn>
          <sortColumnName>lastsold</sortColumnName>
          <sortType>ascending</sortType>
        </sortColumn>
        <sortColumn>
          <sortColumnName>quantityonhand</sortColumnName>
          <sortType>descending</sortType>
        </sortColumn>
      </sortColumns>
    </item>';

$result = array();

$params = array("infoRequestXml" => $request);

try {
    $result = $client->__soapCall('getAllInfo', array("parameters"=>$params));
} catch (SoapFault $e) {
    echo "SOAP Fault: ".$e->getMessage()."<br />n";
}

echo "<pre>";
echo htmlspecialchars($client->__getLastRequestHeaders())."n";
echo htmlspecialchars($client->__getLastRequest())."n";
echo "Response:n".htmlspecialchars($client->__getLastResponseHeaders())."n";
echo htmlspecialchars($client->__getLastResponse())."n";
echo "</pre>"; 

var_dump($result);

?>
Monday, November 28, 2022
 
2

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
 
kentobi
 
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 :