【发布时间】:2012-01-03 20:57:30
【问题描述】:
我尝试使用 PHP 来使用简单的 Web 服务,但不幸的是,我收到以下错误消息(在我看来)说 SOAP URL 无法打开,但在浏览器中它确实可以正常工作(http:// www.webservicex.net/uklocation.asmx?WSDL)。
知道我的错误在哪里吗?
错误消息:
警告: SoapClient::SoapClient(http://www.webservicex.net/uklocation.asmx?WSDL) [soapclient.soapclient]:无法打开流:连接超时 在 /home/sia-deutschland_de/www/tests/test.php 第 14 行
警告:SoapClient::SoapClient() [soapclient.soapclient]:I/O 警告 : 未能加载外部实体 “http://www.webservicex.net/uklocation.asmx?WSDL”在 /home/sia-deutschland_de/www/tests/test.php 第 14 行异常 错误!
SOAP-ERROR:解析 WSDL:无法从 “http://www.webservicex.net/uklocation.asmx?WSDL”:加载失败 外部实体“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();
}
?>
【问题讨论】: