【问题标题】:Karate 0.9.1 is throwing exceptions for soap webservice testing空手道 0.9.1 为肥皂网络服务测试抛出异常
【发布时间】:2019-02-01 13:24:27
【问题描述】:

我正在尝试使用空手道 0.9.1 测试肥皂网络服务,我根据文档创建了场景。

但是当我在测试场景中传递 web 服务请求时测试肥皂 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

谁能帮我理解我在这里做错了什么。

我在空手道 0.6.1 中使用了相同的 xml,它运行良好。

【问题讨论】:

    标签: karate


    【解决方案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

    【讨论】:

    • 我编辑了请求,我实际上在单独的行上使用了三引号。仍然面临同样的问题。
    • @vasantharajan 见上面的最后一行
    • 我的错,那里有一些空间。它按预期工作。感谢您的意见。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    • 1970-01-01
    • 2021-07-29
    • 2017-01-16
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多