Problem Description:
When you use PHP and Java to manipulate XML-RPC, if the request contains Chinese characters, it is automatically encoded in the following style:
Huan Huan.
Environment: PHP built-in XML-RPC Api,apache XML-RPC Java API
The solution under PHP:
At first I thought it was a coding problem for Chinese characters, so I tried encoding Chinese characters in various encodings, and then handed string Xmlrpc_encode_request (string method, mixed params) functions to generate XML-formatted requests. But still. Baffled by the world. Then the Google a god search, also did not find a solution, and later I found the http://xmlrpc-epi.sourceforge.net/this site. Just know that the original PHP document to the Xmlrpc_encode_request (string method, mixed params) function less than an optional parameter!!!! This should be true: String Xmlrpc_encode_request (String method, mixed params [, array output_options])!! The structure of the 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 explains 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 of the request came in. Default = Auto (when Applica BLE), Xmlrpc
Encoding:the encoding that the "data is" in. Since PHP defaults to iso-8859-1 your would usually want to use that. Change it if your know what you are doing. Default=iso-8859-1
The key to the test is that on the value of the "escaping" => Array ("markup"), passing the third argument to the following value solves the problem:
$output _options = Array (
"Output_type" => "xml",
" Verbosity "=>" Pretty ",
"Escaping" => Array ("markup"),
"Version" => "Xmlrpc",
"Encoding" => "Utf-8"
);
Apache JAVA XML-RPC Solution
Search the API provided by the Apache does not seem to find a third parameter like PHP, it is helpless to find that he provided a Base64 class, I had to put all the Chinese characters on the client side of the Base64 code, and then request to the server, Then in the server end with Base64 decoding, haha ~ ~ Problem can also be solved! But I don't know if there's any better way to do it.
Who has a better solution please contact me:
qq:3470431
Msn:imdishui@hotmail.com
Email:wangsg@asiainfo.com