I'm using NuSOAP to interact with a third party API, including running database queries and retrieving the results. It's been working quite reliably, but I just ran into an issue with one specific query. Instead of returning results, NuSOAP generated an error: XML error parsing SOAP payload on line 2: Invalid character
Turns out that the result set contained the following: Léa Lincoln
. When I manually changed the accented character to a "regular" one, the query worked fine with no errors from NuSOAP.
So, my question is how to handle this going forward. I can't control the data coming from the database, and I need for NuSOAP not to throw an error and stop every time there's a non-standard character. Thanks. --Jeff
After searching and testing seems that a hack by CAZypedia crew was the solution:
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;
Link: http://sourceforge.net/projects/nusoap/forums/forum/193579/topic/3718945