I try to consume a simple webservice using PHP unfortunately I get the following error messages wich (as it seems to me) say that the SOAP URL can not be opened, but in the Browser it does work fine (http://www.webservicex.net/uklocation.asmx?WSDL).
Any Idea where is my mistake?
The Errormessages:
Warning: SoapClient::SoapClient(http://www.webservicex.net/uklocation.asmx?WSDL) [soapclient.soapclient]: failed to open stream: Connection timed out in /home/sia-deutschland_de/www/tests/test.php on line 14
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://www.webservicex.net/uklocation.asmx?WSDL" in /home/sia-deutschland_de/www/tests/test.php on line 14 Exception Error!
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.webservicex.net/uklocation.asmx?WSDL' : failed to load external entity "http://www.webservicex.net/uklocation.asmx?WSDL"
And my code:
<?php
// include the SOAP classes
require_once('nusoap.php');
try {
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient("http://www.webservicex.net/uklocation.asmx?WSDL", $options);
// Note where 'Get' and 'request' tags are in the XML
//$client = new soapclient("http://www.webservicex.net/uklocation.asmx?WSDL", $options);
$err = $client->getError();
if ($err) {
// Display the error
echo 'client construction error: ' . $err ;
} else {
$answer = $client->call(’GetUKLocationByCounty’,
array(
'Country'=>'London'));
$err = $client->getError();
if ($err) {
// Display the error
echo 'Call error: ' . $err;
print_r($client->response);
print_r($client->getDebug());
} else {
print_r($answer);
}
}
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
?>
It wasn't really a mistake the solution is quite simple: I installed the code on a shared hosting package and it seems from there internet access is not allowed. From my local system it works fine.