通过网上的webservice自己编写两个客户端
2024-10-06 10:04:42
1.根据电话号码查询归属地等信息
根据http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl采用jdk生成所需的代码,编写一个controller
@RestController
public class Controller { @RequestMapping("/phone")
public String phone(HttpServletRequest request){
String phone = request.getParameter("phone");
//创建一个MobileCodeWS工厂
MobileCodeWS factory = new MobileCodeWS();
//根据工厂创建一个MobileCodeWSSoap对象
MobileCodeWSSoap mobileCodeWSSoap = factory.getMobileCodeWSSoap();
String searchResult = mobileCodeWSSoap.getMobileCodeInfo(phone, null);
return searchResult;
}
}
运行项目,访问http://localhost:8800/phone?phone=18888888888 得到:18888888888:北京 北京 北京移动全球通卡
代码下载:https://github.com/heqiyoujing/WebService
2.根据ip查询所属地
根据http://ws.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl采用jdk生成所需的代码,编写一个controller
@RestController
public class Controller { @RequestMapping("/ip")
public List<String> ip(HttpServletRequest request){
String ip = request.getParameter("ip");
IpAddressSearchWebService service = new IpAddressSearchWebService();
IpAddressSearchWebServiceSoap soap = service.getIpAddressSearchWebServiceSoap();
ArrayOfString ips = soap.getCountryCityByIp(ip);
List<String> list = ips.getString();
return list;
}
}
运行项目,访问http://localhost:9009/ip?ip=192.158.111.21 得到:["192.158.111.21","美国 "]
代码下载:https://github.com/heqiyoujing/WebService
最新文章
- Alpha阶段项目展示
- 速战速决 (2) - PHP: 数据类型 bool, int, float, string, object, array
- rabbitmq学习笔记2 基本概念
- webserver and application server
- HTTP请求中POST与GET的差别
- ERROR: JDWP Unable to get JNI 1.2 environment, jvm->;GetEnv() return code = -2
- AngularJS进阶(三十五)浏览器兼容性解决之道
- 导出MySql中的数据库 --Linux/Windows
- Centos 7 查看内存占用情况相关命令
- oracle ceil函数
- 读C#开发实战1200例子记录-2017年8月14日10:03:55
- ThinkPHP5模型操作中的自动时间戳总结
- linux-shell系列8 netstat用法
- 检测ip和地区
- 《Spring2之站立会议4》
- Java代码解决ElasticSearch的Result window is too large问题
- Mysql 5.5从零开始学阅读笔记
- Linux系统如何迁移至LVM磁盘
- 第一次使用mpvue的小记
- IDEA默认VIM模式