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.
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.
code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/
--> call: PHP page, convert the parameter to UTF - 8 -> WebService, after converting to GBK -> PHP class
return: PhP class -> WebService, after receiving the message, convert it to UTF - 8 -> PHP page, converted to GBK