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

jal*_*rin 4 php xml nusoap

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

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

所以,我的问题是如何处理这个问题.我无法控制来自数据库的数据,我需要NuSOAP不要抛出错误并在每次出现非标准字符时停止.谢谢.--Jeff

Ham*_*mZa 5

在搜索和测试之后,似乎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;
Run Code Online (Sandbox Code Playgroud)

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