【WebService】使用postman调用WebService方法

1、需求

公司原来有一个项目使用的是WebService,想模拟一下怎么调用WebService的方法,使用postman调用怎么调用。

2、postman方式

接口:http://127.0.0.1:8080/SecurityWebService/SecurityCommand?wsdl

对应你的代码配置:

@Configuration
public class WebConfig {

    @Resource
    private BlocCommandReceiveService blocCommandReceiveService;

    @Bean
    public ServletRegistrationBean disServlet() {
        // WebService访问的父路径,可以找到所有wsdl文件
        return new ServletRegistrationBean(
                new CXFServlet(), "/SecurityWebService/*");
    }

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), this.blocCommandReceiveService);
        endpoint.publish("/SecurityCommand");
        return endpoint;
    }

}

注意:Content-Type:text/xml;charset=UTF-8 默认的要注释

接下来解析一下请求xml

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://service.cmcc.databus.idss.com/">
    <soap:Body>
        <test:security_command >
            <odId><![CDATA[123213213]]></odId>
            <randVal><![CDATA[123213213]]></randVal>
            <timeStamp><![CDATA[123213213]]></timeStamp>
            <pwdHash><![CDATA[123213213]]></pwdHash>
            <command><![CDATA[123213213]]></command>
            <commandHash><![CDATA[123213213]]></commandHash>
            <commandType><![CDATA[123213213]]></commandType>
            <commandSequence><![CDATA[123213213]]></commandSequence>
            <encryptAlgorithm><![CDATA[123213213]]></encryptAlgorithm>
            <hashAlgorithm><![CDATA[123213213]]></hashAlgorithm>
            <compressionFormat><![CDATA[123213213]]></compressionFormat>
            <commandVersion><![CDATA[123213213]]></commandVersion>
        </test:security_command>
    </soap:Body>
</soap:Envelope>

xmlns:test: 不能少,必须是这个,参数为代码配置的targetNamespace 。

targetNamespace = "http://service.cmcc.databus.idss.com/"

<test:security_command >: test不变,后面的是方法名称,你代码配置的:如果没有配置就默认方法名称。

@WebMethod(operationName = "security_command")

中间的就是参数了,值必须要包住。<![CDATA[123213213]]>。

之后就可以请求了。
在这里插入图片描述

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞四海

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值