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

最新文章

  1. Alpha阶段项目展示
  2. 速战速决 (2) - PHP: 数据类型 bool, int, float, string, object, array
  3. rabbitmq学习笔记2 基本概念
  4. webserver and application server
  5. HTTP请求中POST与GET的差别
  6. ERROR: JDWP Unable to get JNI 1.2 environment, jvm-&gt;GetEnv() return code = -2
  7. AngularJS进阶(三十五)浏览器兼容性解决之道
  8. 导出MySql中的数据库 --Linux/Windows
  9. Centos 7 查看内存占用情况相关命令
  10. oracle ceil函数
  11. 读C#开发实战1200例子记录-2017年8月14日10:03:55
  12. ThinkPHP5模型操作中的自动时间戳总结
  13. linux-shell系列8 netstat用法
  14. 检测ip和地区
  15. 《Spring2之站立会议4》
  16. Java代码解决ElasticSearch的Result window is too large问题
  17. Mysql 5.5从零开始学阅读笔记
  18. Linux系统如何迁移至LVM磁盘
  19. 第一次使用mpvue的小记
  20. IDEA默认VIM模式

热门文章

  1. S3 Select for Java 使用记录
  2. Spring Boot 支持 Https 有那么难吗?
  3. vue中的虚拟DOM树
  4. Mybatis学习笔记之---多表查询(1)
  5. Source Maps简介
  6. 如何以python风格高逼格的改成购物车逻辑
  7. grep文本搜索工具详解
  8. python学习之并发编程(理论部分)
  9. 如何在不到12天的时间里将网站权重优化到1(纯白帽SEO方法)
  10. odoo模板中的t-标签用法