1、建連接
HttpConnection httpConn = ( HttpConnection ) Connector.open("http://10.0.0.172:80"+{"待訪問URL的相對路徑"});
httpConn.setRequestProperty( "X-Online-Host", {"不含http://的公網(wǎng)ip或域名"});
2、讀取手機號碼
移動網(wǎng)關(guān)設(shè)置,僅限收費wap網(wǎng)址
request.getHeader("X-UP-CALLING-LINE-ID")
3、讀取User-Agent
移動網(wǎng)關(guān)設(shè)置,僅限收費wap網(wǎng)址;也可自行設(shè)置 httpConn.setRequestProperty("User-Agent", App.Useragent);
request.getHeader("User-Agent")
4、讀取二進制流數(shù)據(jù)引起的亂碼問題,安徽和廣西等移動
httpConn.setRequestProperty("Accept-Charset", "utf-8;q=0.5,iso-8859-1;q");
5、傳輸byte[]數(shù)據(jù)到PC
不要設(shè)置Content-Type為application/x-www-form-urlencoded,對數(shù)據(jù)進行url編碼,否則很有可能造成在服務(wù)器無法通過輸入流讀取數(shù)據(jù)。
// conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
真機測試,江蘇移動用戶,南京,通過消息包監(jiān)聽軟件,發(fā)現(xiàn)手機的數(shù)據(jù)發(fā)送情況正常,PC(服務(wù)器)也收到完整的數(shù)據(jù)了,卻無法從輸入流讀到數(shù)據(jù),詳見《手機客戶端與PC服務(wù)器的數(shù)據(jù)交互》。
posted on 2006-08-14 14:19
Xu Jianxiang 閱讀(1094)
評論(0) 編輯 收藏 所屬分類:
Mobile Tech