使用 SpringBoot 集成 WebService [不需要身份验证]

一、使用 JDK 自带的工具生成实体类

# 格式
wsimport -s 保存路径 -p 包路径 -encoding utf-8 wsdl文件地址
# 实例
wsimport -s d:wsdl -p cn.lqdev.webservice -encoding utf-8 http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl

二、将实体类导入到项目中

/**
 * @Description: 客户端的相关调用配置
 * @Date: 2020/03/20
 */
@Configuration
public class WsClientConfig {
    /**
     * @Description: 返回一个 WebServiceSoap 对象
     * @Date: 2020/03/20
     */
    @Bean
    public XxWebServiceSoap getWebServiceSoap(){
        return new XxWebService().getXxWebServiceSoap();
    }
}

三、控制层调用

/**

- @Description:
- @Date: 2020/03/20
  */

@RestController
@RequestMapping("/chenys")
public class QQController {
    @Autowired
    private XxWebServiceSoap xxWebServiceSoap;

@GetMapping("/QQfind/{QQNum}")
public String xxResponse(@PathVariable("QQNum") String QQNum) {
    String s = xxWebServiceSoap.qqCheckOnline(QQNum);
    return s;
}

}
原文地址:https://www.cnblogs.com/damaoa/p/12763334.html