dongzhuner6981 2010-01-05 08:43
浏览 34

PHP错误编码外部引用

I am trying to use a function from SOAP, which will fetch details about a specific news item. The problem is that I don't get the expected results, just a a strange error. I am using the built-in SOAP client in PHP5.

My error is:

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: External reference 'https://newsclient.omxgroup.com/cdsPublic/viewDisclosure.action?disclosureId=379485&messageId=454590' in /home/********/public_html/********/updatenews3.php:15

My code is:

<?php
    $login = '***';
    $password = '***';   
    $client = new SoapClient(
    'https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl',
    array(
        'login' => $login,
        'password' => $password
    ));
    $param = array('lastPublicationId' => 361825);
    $result = $client->fetchNews($param);
?>

The error is the same for all lastPublicationId, where a result is found. It seems as if PHP is trying to load a link, which is found somewhere in the XML-reply (the URL, which is in the error message), and can't access it. Even though I have googled this a lot, I can't find any solution. The only thing I can find is that this seems to have been reported as a bug in a previous version of PHP, but the error refers to PHP 5.2.2 Since I'm using PHP 5.2.9, I'm thinking it can't be that. I'm suspecting the &-character to be the cause of this error?

The WSDL-file can be found here: https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl

Does somebody know this error, and know of any solution?

  • 写回答

1条回答 默认 最新

  • douba3975 2010-01-07 14:44
    关注

    It's possible that the XML being returned by $client->fetchNews($param); isn't being escaped properly - there seems to be an unescaped & in the URL which is shown in the error message.

    Best thing is probably to check exactly what XML is being returned, by turning on tracing and printing the last response:

    $client = new SoapClient(
    'https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl',
    array(
        'login' => $login,
        'password' => $password,
        'trace' => 1
    ));
    $param = array('lastPublicationId' => 361825);
    
    try {
        $result = $client->fetchNews($param);
    }
    catch (SoapFault $sf) {
        print '<pre>';
        // print the exception
        print_r($sf);
    
        // print the XML response
        print $client->__getLastResponse();
    }
    

    A workaround (if the server is returning invalid XML) is to use code similar to the above to catch the exception. You can then manually get at the XML returned (using __getLastResponse()), and clean it up yourself (e.g. using htmlenties or a regexp), before returning it and using it in the rest of your application.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大