原文链接: https://blog.csdn.net/VitaminZH/article/details/81123571
一、使用jdk自带的webservice工具wsimport生成相关类
wsimport -s D:\SvnRepository\Project-Reward\project-reward\reward-server\frame-zone\src\main\java -p com.gmcc.frame.webservice -encoding utf-8 http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl
-s 存储目录;
-p 包名;
-encoding 文件编码,默认会采用操作系统编码,中文为gbk,建议使用utf-8;
二、构建相关的配置类及测试方法
编写配置类:
@Configuration
public class IpConfig {
@Bean
public IpAddressSearchWebServiceSoap webService(){
return new IpAddressSearchWebService().getIpAddressSearchWebServiceSoap();
}
}
编写测试方法:
@RestController
public class Test {
@Autowired
private IpAddressSearchWebServiceSoap soap;
@GetMapping("/searchIp")
public ArrayOfString searchIp(String ip) {
ArrayOfString response = soap.getCountryCityByIp(ip);
return response;
}
}
三、进行接口测试
http://127.0.0.1:29090/test-frame/searchIp?ip=127.0.0.1
最后修改:2019-11-25 07:29:51
© 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

发表评论