spring boot使用SoapClient调用webservice接口

本文介绍了如何在Spring Boot应用中使用SoapClient调用WebService接口。首先通过浏览器获取接口信息,然后利用测试工具SoapUI进行验证。接着详细讲述了代码实现过程,最后鼓励读者亲自尝试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

spring boot 使用SoapClient调用webservice接口

  1. 浏览器打开地址得到对应信息
    示例:测试webservice地址
    信息标注
  2. 使用测试工具(SoapUI 5.4.0)
    soapui使用
    在这里插入图片描述
  3. 代码编写

说明

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

快去试试吧!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值