Php calls webservice interface, garbled code and Error Reporting

Source: Internet
Author: User
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.

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.