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;
}
}
快去试试吧!!!