空手道0.9.1引发肥皂网络服务测试异常

时间:2019-01-31 12:48:33

标签: karate

我试图使用Karate 0.9.1测试肥皂网络服务,我根据文档创建了方案。

但是,当我在测试场景中传递Web服务请求时,我测试Soap Web服务时却出现异常。

方案:1 我通过了以下请求,

* def req=
""" 
  <?xml version='1.0' encoding='UTF-8'?>
  <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
  <ns2:QueryUsageBalance xmlns:ns2="http://www.mycompany.com/usage/V1">
      <ns2:UsageBalance>
          <ns2:LicenseId>12341234</ns2:LicenseId>
      </ns2:UsageBalance>
  </ns2:QueryUsageBalance>
  </S:Body>
  </S:Envelope>
  """

结果

“[Fatal Error] :32:18: XML document structures must start and end within the same entity”

场景:2

Given request
""" 
  <?xml version='1.0' encoding='UTF-8'?>
  <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
  <ns2:QueryUsageBalance xmlns:ns2="http://www.mycompany.com/usage/V1">
      <ns2:UsageBalance>
          <ns2:LicenseId>12341234</ns2:LicenseId>
      </ns2:UsageBalance>
  </ns2:QueryUsageBalance>
  </S:Body>
  </S:Envelope>
  """

结果

“[Fatal Error] :32:18: XML document structures must start and end within the same entity”

场景:3

Given request =
""" 
  <?xml version='1.0' encoding='UTF-8'?>
  <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
  <ns2:QueryUsageBalance xmlns:ns2="http://www.mycompany.com/usage/V1">
      <ns2:UsageBalance>
          <ns2:LicenseId>12341234</ns2:LicenseId>
      </ns2:UsageBalance>
  </ns2:QueryUsageBalance>
  </S:Body>
  </S:Envelope>
  """

结果

Program execution freezes and no output

任何人都可以帮助我了解我在这里做错的事情。

我在Karate 0.6.1中使用了相同的xml,并且工作正常。

1 个答案:

答案 0 :(得分:1)

只需在三行之间加上三引号,就可以了:

* def req =
"""
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:QueryUsageBalance xmlns:ns2="http://www.mycompany.com/usage/V1">    <ns2:UsageBalance>
<ns2:LicenseId>12341234</ns2:LicenseId>
</ns2:UsageBalance>
</ns2:QueryUsageBalance>
</S:Body>
</S:Envelope>
"""
* print req

我们已经要求用户测试Beta版本,但您似乎还没有看到它们:https://twitter.com/KarateDSL/status/1064375506202755073

无论如何,如果仍然出现“冻结”之类的问题,请按照以下过程操作:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue