2011-11-22 112 views
2

我嘗試使用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(); 
} 
?> 

回答

5

這是不是一個真正的錯誤解決方案很簡單:我安裝了一個共享的主機包裝的代碼,它似乎從那裏上網是不允許的。從我的本地系統,它工作正常。

0

此外,就像在我的情況下,問題可以在網址上,我有一個空間開始我的變量,其中包含的網址和導致錯誤。