PHP and Java XML-RPC Chinese problem solution

Source: Internet
Author: User

Problem description:
When you use PHP and Java to manipulate XML-RPC, if the request contains Chinese characters, it will be automatically encoded into the following style:

Huan.

Environment: PhP built-in XML-RPC API, Apache XML-RPC Java API

PHP Solution:
At first, I thought it was a problem of Chinese character encoding, so I tried to encode Chinese Characters in various encoding methods, and then handed it to string xmlrpc_encode_request (string method, mixed Params) function to generate requests in XML format. Best of mind. I tried Google to find a solution, but I found the website http://xmlrpc-epi.sourceforge.net. It is known that the xmlrpc_encode_request (string method, mixed Params) function provided in the original PHP document lacks an optional parameter !!!! It should be correct: String xmlrpc_encode_request (string method, mixed Params [, array output_options])! The structure of output_options is as follows:

$ Output_options = array (
"Output_type" => "XML ",
"Verbosity" => "pretty ",
"Escaping" => array ("markup", "non-ASCII", "non-print "),
"Version" => "XMLRPC ",
"Encoding" => "UTF-8"
);
Or

$ Output_options = array ("output_type" => "php ");

The original text is described as follows:

Output_type: return data as either PHP native data types or XML encoded. ifphp is used, then the other values are ignored. Default = xml

Verbosity: Determine compactness of generated XML. Options are no_white_space, newlines_only, and pretty. Default = pretty

Escaping: Determine how/whether to escape certain characters. 1 or more values are allowed. if multiple, they need to be specified as a sub-array. options are: CDATA, non-ASCII, non-print, and markup. default = non-ASCII, non-print, Markup

Version: version of XML vocabulary to use. currently, three are supported: XMLRPC, soap 1.1, and simple. the keyword auto is also recognized to mean respond in whichever version the request came in. default = auto (when applicable), XMLRPC

Encoding: the encoding that the data is in. Since PHP defaults to iso-8859-1 you will usually want to use that. Change it if you know what you are doing. Default = iso-8859-1

The key to the test is to pass the third parameter into the following value on the value of "escaping" => array ("markup") to solve the problem:

$ Output_options = array (
"Output_type" => "XML ",
"Verbosity" => "pretty ",
"Escaping" => array ("markup "),
"Version" => "XMLRPC ",
"Encoding" => "UTF-8"
);

The solution of Apache Java XML-RPC

After searching for the APIS provided by Apache, it seems that no third parameter like PHP has been found. It is helpless to find that it provides a base64 class, I had to use base64 encoding for all Chinese characters on the client side, request to the server, and then use base64 decoding on the server side ~~~ The problem can also be solved! But I don't know if there are any better solutions?

Please contact me for a better solution:
QQ: 3470431
MSN: imdishui@hotmail.com
Email: wangsg@asiainfo.com

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.