Soap客户端-SoapClient
使用
- 使用SoapUI解析WSDL地址,找到WebService方法和参数。
- 按照SoapUI中的相应内容构建SOAP请求。
- 方法名为:
- 定义了一个命名空间,前缀为
web
,URI为http://WebXml.com.cn/
SoapClient client = SoapClient.create("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
// 设置要请求的方法,此接口方法前缀为web,传入对应的命名空间
.setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
.setParam("theIpAddress", "218.21.240.106");
// 发送请求,参数true表示返回一个格式化后的XML内容
Console.log(client.send(true));