【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


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://service.cmcc.databus.idss.com/">
    <soap:Body>
        <test:security_command >
            <odId>odId>
            <randVal>randVal>
            <timeStamp>timeStamp>
            <pwdHash>pwdHash>
            <command>command>
            <commandHash>commandHash>
            <commandType>commandType>
            <commandSequence>commandSequence>
            <encryptAlgorithm>encryptAlgorithm>
            <hashAlgorithm>hashAlgorithm>
            <compressionFormat>compressionFormat>
            <commandVersion>commandVersion>
        test:security_command>
    soap:Body>
soap:Envelope>

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

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

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

@WebMethod(operationName = "security_command")

中间的就是参数了,值必须要包住。

之后就可以请求了。
【WebService】使用postman调用WebService方法_第1张图片

你可能感兴趣的:(疑难杂症与需求,postman,测试工具)