spring boot 使用SoapClient调用webservice接口
- 浏览器打开地址得到对应信息
示例:测试webservice地址

- 使用测试工具(SoapUI 5.4.0)


- 代码编写

public String webServicePostTest(){
String result = "";
try{
SoapClient client = SoapClient.create("http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx")
.header("SOAPAction","http://WebXml.com.cn/getMobileCodeInfo")
.setMethod("web:getMobileCodeInfo", "http://WebXml.com.cn/")
.setParam("mobileCode","<![CDATA[13203389752]]>",true)//值需要使用 <![CDATA[值]]>
.setParam("userID","<![CDATA[]]>",false);//此处写true,会自动填写命名空间
result = client.send(false);
result = soapXml(result,"");
log.error("出参:{}",result);
return result;
}catch (Exception ex){
throw ex;
}
}
快去试试吧!!!
本文介绍了如何在Spring Boot应用中使用SoapClient调用WebService接口。首先通过浏览器获取接口信息,然后利用测试工具SoapUI进行验证。接着详细讲述了代码实现过程,最后鼓励读者亲自尝试。
1894

被折叠的 条评论
为什么被折叠?



