用aspx做了个页面,用wap方式访问取一个http头,返回给客户端。aspx的代码:
  Response.Clear();
  Response.Write("value:" + Request.Headers["x-up-calling-line-id"]);android客户端的:String getText = getUrlContent("http://61.155.219.194/GetSIM.aspx",5000);public final static String getUrlContent(String url,int timeOut){
String str = "";
try {
URL aURL = new URL(url);
URLConnection conn = aURL.openConnection();
conn.connect();
StringBuilder b = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));

String line;
while ((line = reader.readLine()) != null) {
b.append(line);
}

reader.close();
str = b.toString();
//Log.d(TAG, "getUrlContent OK:" + url);
} catch (IOException e) {
//Log.e(TAG, "getUrlContent Error!"+url, e);
return "";
} catch (Exception e) {
//Log.e(TAG, "getUrlContent unknown Error!"+url, e);
return "";
}
return str;
}
现在的问题是:
我手机网络的接入选择为WAP方式。
用手机自带的浏览器访问我的页面,显示:value:189xxxxxxxx
用手机上我写的代码来访问,getText的值只有 "value:"请教高手这是什么情况,如果修改代码或者配置文件来修复?小菜鸟不胜感激!!

解决方案 »

  1.   

    设置一下wap代理
    用URL.openConnection(Proxy proxy)
      

  2.   

    感谢1楼!
    附上设置wap代理的代码:             // 获取默认代理主机ip
                  String host = android.net.Proxy.getDefaultHost();
                  // 获取端口
                  int port = android.net.Proxy.getDefaultPort();
                  
                  //封装代理连接主机IP与端口号。
                  InetSocketAddress inetAddress = new InetSocketAddress(host, port);
                  // 根据URL链接获取代理类型,本链接适用于TYPE.HTTP
                  java.net.Proxy.Type proxyType = java.net.Proxy.Type.valueOf(url
                                  .getProtocol().toUpperCase());
                  java.net.Proxy javaProxy = new java.net.Proxy(proxyType, inetAddress);
                  URLConnection conn = (HttpURLConnection) url.openConnection(javaProxy);
           
                  conn.connect();