WebService, which must be familiar to everyone, is a way for the "service provider" to provide services to the "service caller. There are several key technologies:
XML: Standard Method for describing data
SOAP: Simple Object Access Protocol for information exchange
WSDL: Web Service Description Language
UDDI: Universal Description, discovery, and integration. It is a platform-independent, XML-based protocol used to describe commerce on the Internet.
By default, SOAP transmits UTF-8 encoding, which also determines that WebService uses UTF-8 encoding by default.
Currently, the maintained Project is a PHP project, and the encoding is all using GBK. When you call the WebService method provided by yourself, you will encounter Encoding Problems. The PHP page calls WebService, which calls another PHP class that calls the COM component. This is probably the case.Copy codeThe Code is as follows: PHP page (GBK)-> WebService (UTF-8)-> PHP class (GBK)
Before you encounter any problems, everything was calm, and it took many years. One day, the company acquired other companies. In order to integrate services, user information was also integrated. The accounts of all users of the original company were composed of English characters and numbers, the acquired company has not made such a limit, and the account has Chinese characters. After integration, the problem occurs. "error in msg parsing: XML error parsing SOAP payload on line 1: Invalid character [detail]"!
PHP is not very familiar with it just recently, and the debugging of NetBeans is often poor. So open VS, reference WebService, and start testing. Returned results, can not find the user, and is garbled, OK, after a look, because the WebService UTF-8 encoding to PHP class, encoding inconsistency caused! Convert to GBK and pass it back. After receiving the data, find the user, but garbled. After converting the returned data to the UTF-8 again, everything is OK! Test everything in! On the testing machine! Start testing! Garbled characters are displayed! Still "error in msg parsing: XML error parsing SOAP payload on line 1: Invalid character [detail!
Calm down and continue the analysis! It should be caused by WebService calls on the PHP page! The test page below VS is UTF-8 and there is no problem between them, but this page of PHP is GBK. After the change, everything becomes calm again.Copy codeThe Code is as follows: Call: PHP page, parameter conversion to UTF-8-> WebService, after conversion to GBK-> PHP class
Return: PHP class-> WebService, after receiving, convert to UTF-8-> PHP page, convert to GBK