一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP和JAVA的XML-RPC中文問題解決辦法

      問題描述:
      在使用phpJava操作XML-RPC的時候,如果request中包含中文字符,會被自動編碼成如下樣式:

欢欢 。

      環(huán)境:php內(nèi)置XML-RPC的API,Apache的XML-RPC的Java API

      php下的解決方法:
      起初以為是中文字符的編碼問題,所以我就嘗試用各種編碼方式來編碼中文字符,然后交給string xmlrpc_encode_request ( string method, mixed params)函數(shù)來生成XML格式的請求,可是依然如故。百思不得其界。便操其Google 一通神搜,也沒找到解決辦法,后來我找到了http://xmlrpc-epi.sourceforge.NET/這個網(wǎng)站。才知道,原來php文檔里給的xmlrpc_encode_request ( string method, mixed params)函數(shù)少了一個可選參數(shù)!!!!正確的應(yīng)該是這樣的:string xmlrpc_encode_request(string method, mixed params [, array output_options])!!output_options的結(jié)構(gòu)如下:

$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 (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

經(jīng)過測試關(guān)鍵是在"escaping" => array("markup")這個值上,將第三個參數(shù)傳入如下值就可以解決問題了:

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


      Apache Java XML-RPC的解決方法

     找遍了Apache提供的API好像也沒有找到類似php那樣的第三個參數(shù),實在無奈發(fā)現(xiàn)他提供了一個Base64的類,我便只好將所有的中文字符在Client端用 Base64編碼,然后request到Server上,然后在Server端在用Base64解碼,哈哈~~~問題也能解決!不過不知道還有沒別的更好的辦法了?

     誰有更好的解決方法請和我聯(lián)系:
     QQ:3470431
     MSN:imdishui@hotmail.com
     Email:wangsg@asiainfo.com

php技術(shù)PHP和JAVA的XML-RPC中文問題解決辦法,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产成人午夜片在线观看 | 日韩美女强理论片 | 色视频网站大全免费 | 午夜黄色大片 | 最新亚洲情黄在线网站 | 亚洲综合在线成人一区 | 美女精品一区二区 | 国产高清a | 丁香激情六月天 | 亚洲乱人伦精品图片 | 色国产精品| 精品国产高清a毛片无毒不卡 | 国产国产成人久久精品杨幂 | 国产精品区免费视频 | 最新精品国偷自产在线91 | 五月激情丁香婷婷综合第九 | 最新国产在线观看福利 | 伊人青草| 欧美精品v国产精品v日韩精品 | 亚洲第一网站免费视频 | 中文字字幕码一二区 | 99成人国产精品视频 | 一区二三区国产 | 精品一区二区三区在线视频 | 41sao.can在线观看国产 | 欧美成人综合视频 | 精品亚洲成a人在线观看 | 天天搞天天色 | 国产乱论视频 | 亚洲视频在线一区二区 | 国产日韩欧美91 | 国产精品日本不卡一区二区 | 一起射福利| 久久伊人成人 | 国产精品免费_区二区三区观看 | 日本精品1在线区 | 永久黄网站色视频免费观看 | 好吊妞视频免费观看va | 四色成人网 | 偷自在线 | 亚洲一区二区三区中文字幕 |