PHP XML Error parsing SOAP payload on line 1_php tips

Source: Internet
Author: User
Tags soap php class
WebService, presumably everyone is familiar with, is a way of providing service to the service caller by the "service provider". There are several key technologies:

XML: A standard way to describe data
SOAP: Simple Object Access protocol for information exchange
Wsdl:web Service Description Language
UDDI: Universal Description, Discovery, and integration, a platform-independent protocol for describing business on the Internet, based on an XML language.

Soap defaults to the UTF-8 encoding, which also determines that WebService is UTF-8 encoded by default.

The project that is now maintained is a PHP project with all the GBK, and the coding problem is encountered when invoking the WebService method provided by itself. The PHP page calls WebService, and this webservice calls another PHP class that calls COM components. That's probably what the scene is.
Copy Code code as follows:

PHP page (GBK)-> WebService (UTF-8)-> PHP class (GBK)

Everything was calm before we had a problem, and it took many years. One day, the company acquired other companies, in order to integrate services, user information is also integrated together, the original company all user accounts are composed of English characters alphanumeric figures, and the acquisition of the company did not do such a qualification, the account has the situation of Chinese characters. After the integration, the problem arose, "Error in msg parsing:xml error parsing SOAP payload on line 1:invalid character [detail]"!

PHP has just come in contact, not very well, and the debugging of NetBeans is often hard to complete. So just open vs, quote WebService, and start testing. Return the result, can not find the user, and is garbled, OK, looked at after, because WebService UTF-8 encoding to the PHP class, encoding inconsistent results! Convert to GBK again pass past, receive the data, find the user, but still garbled. After converting the returned data back to UTF-8, everything ok! VS under Test everything is OK! On the test machine! Start the test! After opening, garbled! is still "error in msg parsing:xml error parsing SOAP payload on line 1:invalid character [detail]" embarrassing!

Calm down and continue to analyze! It should be caused by the PHP page call WebService! vs the test page below is UTF-8, there is no problem between them, but this page of PHP is GBK. Once again, everything was back to calm.
Copy Code code as follows:

Call: PHP page, parameter conversion to UTF-8-> WebService, convert to GBK-> PHP class
Return: PHP class-> Web Service, converted to UTF-8-> PHP page after receiving, convert to GBK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.