永利皇宫463手机版PHP和JAVA的XML-RPC中文问题解决办法_php基础_脚本之家

难题汇报:
在接受PHP和JAVA操作XML-RPC的时候,假若request中包罗汉语字符,会被自动编码成如下样式:

欢欢 。

环境:PHP内置XML-RPC的API,Apache的XML-RPC的JAVA API

PHP下的缓和方法:
发轫以为是中文字符的编码难题,所以小编就尝试用各个编码格局来编码中文字符,然后交到string
xmlrpc_encode_request ( string method, mixed
params卡塔尔国函数来生成XML格式的供给,然则照旧照旧。百思不得其界。便操其Google一通神搜,也没找到消除办法,后来小编找到了
( string method, mixed
params卡塔尔(قطر‎函数少了一个可选参数!!!!正确的相应是如此的:string
xmlrpc_encode_request(string method, mixed params [, array
output_options])!!output_options的布局如下:

$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”);

最早的文章表明如下:

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 , 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

透过测量检验首假若在”escaping” =>
array这几个值上,将第五个参数字传送入如下值就足以缓慢解决难点了:

$output_options = array( “output_type” => “xml”, “verbosity” =>
“pretty”, “escaping” => array, “version” => “xmlrpc”, “encoding”
=> “utf-8” );

Apache JAVA XML-RPC的解决措施

找遍了Apache提供的API好像也绝非找到相符PHP这样的第八个参数,实在没办法开采他提供了二个Base64的类,笔者便只好将具备的国语字符在Client端用
Base64编码,然后request到Server上,然后在Server端在用Base64解码,哈哈~~~难题也能解除!但是不知道还会有没别的越来越好的秘技了?

何人有更加好的缓慢解决措施请和自身联络: QQ:3470431 MSN:imdishui@hotmail.com
Email:wangsg@asiainfo.com

发表评论

电子邮件地址不会被公开。 必填项已用*标注