【WebService】使用postman调用WebService方法

1、需求

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

2、postman方式

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

对应你的代码配置:

java 复制代码
@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 复制代码
<?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 。

xml 复制代码
targetNamespace = "http://service.cmcc.databus.idss.com/"

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

xml 复制代码
@WebMethod(operationName = "security_command")

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

之后就可以请求了。

相关推荐
光影6273 小时前
Selenium自动化测试---实战踩坑实录
python·selenium·测试工具·百度
掌动智能5 小时前
传统数据工厂之死:RunnerAgent如何开启AI驱动的“数据生产”新纪元
人工智能·测试工具·自动化
wuchen10041 天前
使用Postman测试grpc接口-传参错误的反例
测试工具·postman
蒲公英内测分发1 天前
Typeoff 实时润色体验:语音转文字让写作效率提升 3 倍
测试工具·产品运营·项目管理
Luminbox紫创测控1 天前
氙灯太阳光模拟器加速老化测试
人工智能·测试工具·测试标准
wangl_921 天前
Wireshark 使用指南:从入门到高级分析
网络·网络协议·tcp/ip·测试工具·wireshark·modbus
wuchen10041 天前
使用Postman测试grpc接口
postman·grpc
Byron Loong1 天前
【网络】Wireshark过滤器表达式的规则
网络·测试工具·wireshark
MESMarketing1 天前
互动分享 | Shift-Left实践落地
功能测试·测试工具·自动化·自动驾驶·敏捷开发
lifewange2 天前
主流性能诊断工具
测试工具