【问题标题】:soapclient returns failed to load external entitysoapclient 返回加载外部实体失败
【发布时间】: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(); 
}
?>

【问题讨论】:

    标签: php soap wsdl nusoap


    【解决方案1】:

    这并不是一个错误,解决方案非常简单:我将代码安装在共享主机包上,但似乎不允许从那里访问互联网。在我的本地系统上它工作正常。

    【讨论】:

      【解决方案2】:

      另外,就像我的情况一样,问题可能出在 url 上,我的变量开头有一个空格,其中包含 url 并导致错误。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-05-06
        • 1970-01-01
        • 2012-08-28
        • 1970-01-01
        • 1970-01-01
        • 2022-11-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多