前言:

由于工作所需,需要使用Postman测试工具,对基于ws规范的WebService接口进行测试.在经过多种尝试后,终于找到了正确的测试方法.下面我便详细记录测试步骤,以便以后再次测试时可以拿来主义.

第一步:确保WebService服务端正常启动(注意服务端各个接口发布的url地址)

第二步:打开Postman测试工具,查看测试接口对应的wsdl接口文档

注意:GET方法,然后输入WebService服务端发布的正确的url地址,点击Send

 

基于ws规范的WebService,可以自动生成对外接口文档,但这个文档可读性很低,因为它不是给开发人员看的,而是给JDK提供的(之前写过的关于WebService的博客连接:https://www.cnblogs.com/ubiquitousShare/p/12535296.html);

但是因为后边测试的时候要用到里面的一些东西, 所以在这里需要解析文档中的几点重要内容:

 

 第三步:测试接口

 3.1 设置Headers类型

Content-Type : text/xml

Accept-Charset  : charset=utf-8 (以免出现中文乱码现象)

 

 3.2 设置请求体内容,发送请求

注意两个地方:

1).请求方式为POST

2).请求体

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pm="http://api.model.kd.com/">
  <soap:Body>
    <pm:syncIt>
      <arg0>[{"assetNo":"1","barCode":"1","belongDept":"1","boxBarCode":"1","cap":"1","chkDate":1586448000000,"contractId":"1","curStatusCode":"1","dataSrc":"1","descardDate":1586448000000,"discardReason":"1","docCreateDate":1586448000000,"docCreatorNo":"1","eqipPrc":"1","erpBatchNo":"1","fstRcCode":"1","i":0.0001,"insulationMode":"1","itId":"1","lotNo":"1","madeDate":1586880000000,"madeNo":"1","manufacturer":"1","measPrincipleCode":"1","modelCode":"1","newFlag":"1","p":0.0003,"pf":"1","prCode":"1","prOrg":"1","ratedFreqCode":"1","rcRatioCode":"1","rcvId":"1","rotateCycle":"1","rvCode":"1","sndRvCode":"1","sortCode":"1","storeAreaId":"1","storeLocId":"1","taLightLoad":"1","taPreCode":"1","taRatedSndLoad":"1","taTurns":"1","tvLightLoad":"1","tvPreCode":"1","tvRatedSndLoad":"1","tvTurns":"1","typeCode":"1","v":0.0002,"voltRatioCode":"1","whAreaId":"1","whId":"1","windingConfigCode":"1","wiringMode":"1"}]</arg0>
    </pm:syncIt>
  </soap:Body>
</soap:Envelope>

 

值得注意的是测试对应的接口名称和参数类型名称都是wsdl文档中的名称,而不是Java代码中的名称

请求路径,请求头,请求体设置好后,就可以发送请求了

请求成功标志

 

版权声明:本文为ubiquitousShare原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/ubiquitousShare/p/12681382.html