我嘗試使用PHP使用PHP的一個簡單的Web服務,不幸的是我得到以下錯誤消息(至於我看來)說,SOAP URL無法打開,但在瀏覽器中它確實工作正常(http://www.webservicex.net/uklocation.asmx?WSDL)。soapclient返回無法加載外部實體
任何想法哪裏是我的錯誤?
的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"
而且我的代碼:
<?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();
}
?>