繁体   English   中英

使用NuSOAP检索结果时出现XML错误(无效字符)

[英]XML error (Invalid Character) when retrieving results with NuSOAP

我正在使用NuSOAP与第三方API进行交互,包括运行数据库查询和检索结果。 它的运行相当可靠,但是我遇到了一个特定查询的问题。 NuSOAP没有返回结果,而是生成了一个错误: XML error parsing SOAP payload on line 2: Invalid character

事实证明结果集包含以下内容: Léa Lincoln 当我手动将带重音符号的字符更改为“常规”字符时,查询工作正常,并且NuSOAP没有错误。

因此,我的问题是如何处理这一问题。 我无法控制来自数据库的数据,并且我需要NuSOAP不要在每次出现非标准字符时都抛出错误并停止。 谢谢。 -杰夫

经过搜索和测试后,似乎解决了CAZypedia小组的黑客行为:

function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
    parent::nusoap_base();

    // Hack by CAZypedia crew to fix character encoding of NCBI XML data from SOAP
    // This prevents non-English characters from causing the parser to choke.
    $xml = iconv("ISO-8859-1", "UTF-8//TRANSLIT", $xml);
    // End hack.
    $this->xml = $xml;
    $this->xml_encoding = $encoding;
    $this->method = $method;
    $this->decode_utf8 = $decode_utf8;

链接: http//sourceforge.net/projects/nusoap/forums/forum/193579/topic/3718945

我有同样的问题,我通过在文件nusoap.php和class.nusoap_base.php中更改行var $ soap_defencoding ='UTF-8'来解决了

在这些文件中,有两行,$ soap_defencoding ='UTF-8'和$ soap_defencoding ='ISO-8859-1',其中一行被注释,另一行没有注释。

我尝试将评论从一个选项移到另一个,并且成功了!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM