Php calls webservice interface, garbled code and Error Reporting $ Client = new SoapClient ('http: // www.webxml.com.cn/WebServices/TraditionalSimplifiedWebService.asmx? Wsdl ');
$ Client-> soap_defencoding = 'utf-8 ';
$ Client-> decode_utf8 = false;
$ Obj = $ client-> toTraditionalChinese (array ('stext '=> '));
Print_r ($ obj );
?>
This is a webservice code that I wrote to call the web Public simple conversion, I have specified soap_defencoding as the UTF-8, decode_utf8 is set to false, but after the execution of the prompt [Encoding: string '\ xb8... 'is not a valid UTF-8 string]
Please help us to see how to handle this.
Reply to discussion (solution)
Encoding: string '\ xb8...' is not a valid UTF-8 string
The passed parameter is not a UTF-8 string
That is to say, your array ('stext '=>' is not UTF-8
That is to say, your program file is not UTF-8
However, if it is UTF-8, why should we declare the character set?
In addition
$ Client-> soap_defencoding = 'utf-8 ';
$ Client-> decode_utf8 = false;
Is the method of nusoap
Encoding: string '\ xb8...' is not a valid UTF-8 string
The passed parameter is not a UTF-8 string
That is to say, your array ('stext '=>' is not UTF-8
That is to say, your program file is not UTF-8
However, if it is UTF-8, why should we declare the character set?
In addition
$ Client-> soap_defencoding = 'utf-8 ';
$ Client-> decode_utf8 = false;
Is the method of nusoap
I also wrote it in nusoap mode. although no error is reported when executing php, what is the result ???, It is also garbled. I can save both soapclient and nusoap files as UTF-8 files, without using the well-known character set.
Is it possible to save files only in UTF-8 format?
Soap transmits data through xml
The default character set of xml is UTF-8, so if the character set is not declared, it is UTF-8.
Your application actually needs to use gbk (as shown in the error message)
Therefore, when using nusoap, you need $ client-> soap_defencoding = 'gbk ';
Or modify the nusoap code.
When using php's built-in SoapClient
Need $ client = new SoapClient ('http: // www.webxml.com.cn/WebServices/TraditionalSimplifiedWebService.asmx? Wsdl ', array ('encoding' => 'gbk '));
Add:
Your sample code sends a "number"
Should return a "?"
Thank you for your guidance. I just learned a little about this part.
Thank you for solving the problem.