首页 > 分享 > WebService通过Get方式调用第三方查询电话号码归属地

WebService通过Get方式调用第三方查询电话号码归属地

最新推荐文章于 2019-02-14 13:23:07 发布

小小杜w 于 2018-05-17 09:20:05 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

/**
 * 调用第三方服务查询电话号码归属地服务
 * @author dw
 * @Time 2018/5/16
 *
 */
public class MobileCodeService {

//1.get方式访问WebService
public void get(String mobileCode,String userID) throws IOException{
URL url = new URL("http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode="+mobileCode+"&userID="+userID);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//设置延时时间
conn.setConnectTimeout(5000);
//设置请求方式
conn.setRequestMethod("GET");
if (conn.getResponseCode()==HttpURLConnection.HTTP_OK) { //连接成功200
InputStream is = conn.getInputStream();
//内存流
ByteArrayOutputStream boas = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = -1;
//边读边写,从外部读进来,再写进内存
while((len = is.read(buffer))!=-1){
boas.write(buffer, 0, len);
}
System.out.println("Get请求获取的数据:"+boas.toString());
boas.close();
is.close();

}
public static void main(String[] args) throws IOException {

MobileCodeService ws = new MobileCodeService();
ws.get("1388983****", "");
}

相关知识

.NET单元测试的艺术
西宁农村商业银行联行号查询
查询是否包含字符串
花语箴言API接口
附近花店订花电话号码
使用Python调用mysql
base
兰州安宁花店电话号码
基于SSM花卉商城设计与实现
基于ssm网上花店销售管理系统(源码+开题)

网址: WebService通过Get方式调用第三方查询电话号码归属地 https://m.huajiangbk.com/newsview541271.html

所属分类:花卉
上一篇: 原来推导平方差公式a²
下一篇: Opencv3笔记28——直方图