日期:2014-05-20 浏览次数:20785 次
Consts.debug="启用http代理连接"; httpConn = (HttpConnection) Connector.open("http://10.0.0.172:80/kjava.portal?action=xxx"); httpConn.setRequestMethod(HttpConnection.GET);//需要改成GET请求 httpConn.setRequestProperty("X-Online-Host", "wap.5bingo.cn"); httpConn.setRequestProperty("Connection", "Keep-Alive"); httpConn.setRequestProperty("Accept","*/*"); Consts.debug="连接状态:"+httpConn.getResponseCode();//打印出400 if (HttpConnection.HTTP_OK == httpConn.getResponseCode()) { }else{ }
public static String bin2hex(String bin) throws UnsupportedEncodingException { char[] digital = "0A1B2C3D4E5F6789".toCharArray(); StringBuffer sb = new StringBuffer(""); byte[] bs = bin.getBytes("utf-8"); int bit; for (int i = 0; i < bs.length; i++) { bit = (bs[i] & 0x0f0) >> 4; sb.append(digital[bit]); bit = bs[i] & 0x0f; sb.append(digital[bit]); } return sb.toString(); }
String hex=bin2hex("action=xxx"); httpConn = (HttpConnection) Connector.open("http://10.0.0.172:80/kjava.portal?"+hex); httpConn.setRequestMethod(HttpConnection.POST);//需要改成POST请求 httpConn.setRequestProperty("X-Online-Host", "wap.5bingo.cn"); httpConn.setRequestProperty("Connection", "Keep-Alive"); httpConn.setRequestProperty("Accept","*/*");