PHP and Java xml-rpc Chinese problem Solving _php tutorial

Source: Internet
Author: User
Problem Description:
When using PHP and Java to manipulate XML-RPC, if the request contains Chinese characters, it is automatically encoded into the following style:

Huan Huan.

Environment: PHP built-in XML-RPC's Api,apache java API xml-rpc

Workaround under PHP:
At first I thought it was a coding problem for Chinese characters, so I tried to encode Chinese characters in various encodings, and then handed the string Xmlrpc_encode_request (string method, mixed params) function to generate XML-formatted requests. But still. It is not a world of thought. Then the Google a pass God search, also did not find a solution, then I found http://xmlrpc-epi.sourceforge.net/this site. Only to know that the original PHP document to the Xmlrpc_encode_request (string method, mixed params) function is an optional parameter!!!! The correct one should be this: 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 description is as follows:

Output_type:return data as either PHP native data types or XML encoded. Ifphp is used and 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 is 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 is 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 are in. Since PHP defaults to iso-8859-1 you'll usually want to use that. Change the IT if you know what is doing. Default=iso-8859-1

After testing the key is in the "escaping" = = Array ("markup") this value, the third parameter passed to the following value to solve the problem:

$output _options = Array (
"Output_type" = "xml",
"Verbosity" = "Pretty",
"Escaping" = = Array ("markup"),
"Version" = "Xmlrpc",
"Encoding" = "Utf-8"
);


Apache JAVA Xml-rpc Workaround

The API provided by Apache did not seem to find a third parameter like PHP, but I found that he provided a Base64 class, I had to put all the Chinese characters on the client side with BASE64 code, and then request to the server, Then in the server side with Base64 decoding, haha ~ ~ ~ Problem can also be solved! But I don't know if there's any better way.

Who has a better solution please contact me:
qq:3470431
Msn:imdishui@hotmail.com
Email:wangsg@asiainfo.com

http://www.bkjia.com/PHPjc/313778.html www.bkjia.com true http://www.bkjia.com/PHPjc/313778.html techarticle problem Description: When using PHP and Java operation Xml-rpc, if the request contains Chinese characters, it will be automatically encoded into the following style:. Environment: PHP built-in Xml-rpc api,apache ...

  • 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.