gangkou/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/wsdl/TestWsdl.java

36 lines
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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));
}
}