package com.ruoyi.common.wsdl; import cn.hutool.core.lang.Console; import cn.hutool.http.webservice.SoapClient; import javax.xml.soap.SOAPMessage; /** * 测试调用wsdl接口 * @author laijiangfeng * @date 2024/9/27 9:51 */ public class TestWsdl { public static void main(String[] args) throws Exception { // 新建客户端 SoapClient client = SoapClient.create("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx") // 设置要请求的方法,此接口方法前缀为web,传入对应的命名空间 .setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/") // 设置参数,此处自动添加方法的前缀:web .setParam("phone", "18437762352") .setParam("msg", "1112121") .setParam("dwdm", "SGJT-山港集团"); // 发送请求,参数true表示返回一个格式化后的XML内容 // 返回内容为XML字符串,可以配合XmlUtil解析这个响应 Console.log(client.send(true)); } }