package com.service.get;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class WebseriveGet {
public static void main(String[] args) throws IOException {
WebseriveGet webBet = new WebseriveGet();
webBet.Get("11111111111", "");
}
public void Get(String mobileCode, String userID) throws IOException {
int len;
URL url = new URL(
"http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode="+ mobileCode+"&userID=" + userID); ;
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(3000);
ByteArrayOutputStream b = new ByteArrayOutputStream();
conn.setRequestMethod("GET");
if (conn.getResponseCode() == 200) {
InputStream in = conn.getInputStream();
byte[] data = new byte[1024];
while ((len = in.read(data)) != -1) {
b.write(data,0,len);
}
}
System.out.println("mobileNumber: "+b.toString());
b.close();
}
}