& Nbsp; problem description: & nbsp; when using php and java to operate xml-RPC, if the request contains Chinese characters, it will be automatically encoded as follows: & #27426; & #27426 ;. & Nbsp; environment: PHP built-in XML-RPC API, Apache XML-RPC JAVAAPI & nbsp; PHP under the solution: & nbsp; at first thought it is in the problem description:
When you use php and java to operate xml-RPC, if the request contains Chinese characters, the request will be automatically encoded as follows:
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