Soap-Error: Parsing Wsdl: Couldn't Load from <Url>

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

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.

php soapclient wsdl SOAP-ERROR: Parsing WSDL: Couldn't load from

It often happens that providers neglect their SSL certificates and hence the sites and services end up having an invalid certificates - I suspect this is the case here.

Disabling the certificate validation as described by Kaii here or even better get your provider to fix their certificate.

Your code could/should then be something like:

$url     = "https://sampleurl.com/MerchantQueryService.asmx?WSDL ";
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
));

$rq = ["userName" => "username_here",
"passWord" => "password_here",
"referenceId" => "3455566694",
"msisdn" => "346774313"];

$service = new SoapClient($url, array('stream_context' => $context));
$service->RequestTransaction($rq);


Related Topics



Leave a reply



Submit