代码之家  ›  专栏  ›  技术社区  ›  plaidshirt

SoapUI从Groovy中的响应获取附件

  •  0
  • plaidshirt  · 技术社区  · 6 年前

    Groovy

    def testStep = testRunner.testCase.getTestStepByName("getData")
    def response = testStep.testRequest.response
    def ins =  response.attachments[0].inputStream
    log.info(ins);
    

    它也包含一些二进制信息,因此它不是完全可读的,但在输出中得到了以下结果:

    java.io。ByteArrayInputStream@5eca74

    1 回复  |  直到 6 年前
        1
  •  0
  •   plaidshirt    6 年前

    简单地将其编码为base64并将其存储为属性值是很容易的。

    def ins =  response.attachments[0].inputStream
    String encoded = ins.bytes.encodeBase64().toString()