來源:http://dev.10086.cn/cmdn/wiki/index.php?doc-view-5050.html
CMWAP和CMNET只是中國移動爲其劃分的兩個GPRS接入方式。中國移動對CMWAP作了一定的限制,主要表現在CMWAP接入時只能訪問 GPRS網絡內的IP(10.*.*.*),而無法通過路由訪問Internet,我們用CMWAP瀏覽Internet上的網頁 就是通過WAP網關協議或它提供的HTTP代理服務實現的。 因此,只有滿足以下兩個條件的應用 才能在中國移動的CMWAP接入方式下正常工作:
1.應用程序 的網絡請求基於HTTP協議。
2.應用程序 支持HTTP代理協議或WAP網關協議。
這也就是爲什麼我們的G1無法正常用CMWAP的原因。
一句話:CMWAP是移動限制的,理論上只能上WAP網,而CMNET可以用GPRS瀏覽WWW
方法一:
URL url = new URL("http://10.0.0.172/img/baidu_logo.gif");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-Online-Host", "www.baidu.com");
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
is.close();
conn.disconnect();
方法二:
CODE:
package org.apache.http.examp les.client;
import org.apache.http.Header;import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
public class ClientExecuteProxy {
public static void main(String [] args)throws Exception {
HttpHost proxy = new HttpHost( "10.0.0.172", 80, "http");
HttpHost target = new HttpHost("YOUR_TARGET_IP", 80, "http");
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
HttpGet req = new HttpGet("/");
System.out.println("executing request to " + target + " via " + proxy);
HttpResponse rsp = httpclient.execute(target, req);
HttpEntity entity = rsp.getEntity();
System.out.println("----------------------------------------");
System.out.println(rsp.getStatusLine());
Header[] headers = rsp.getAllHeaders();
for (int i = 0; i< i++)>
System.out.println(headers);
}
System.out.println("----------------------------------------");
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
}