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
paramsState of Qatar函数少了八个可选参数!!!!正确的应有是那样的: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

发表评论

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