从响应中剥离引号并传输到请求端点

Stripping quotes from response and transferring to request endpoint

我正在使用 SoapUI 测试一些 REST api。作为响应,我得到 URL 应该是下一个请求的端点。

我做了以下属性转移步骤

source : myApiCall
property : response

target : myHttpCall
property : endpoint

一切正常,但传输时端点看起来像 "www.myurl.com"(带引号),因此无效。我如何从那里删除引号?

原始回复:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 98
Content-Type: application/json; charset=utf-8
Expires: Tue, 25 Oct 2016 09:04:28 GMT
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Tue, 25 Oct 2016 09:04:28 GMT

"http://myurl.com/query?queryUid=90e97bdb-00a3-47c2-8809-c15ceec6ea1b"

问题是您的 Raw 响应在字符串中包含 " 引号。然后你有两个可能的解决方案,从 Raw 响应中删除 " 并继续使用相同的 属性 传输。

或者,如果您无法更改响应,则可以使用 Groovy 脚本 testStep 来获取 Raw 响应并在设置端点之前对其进行操作以删除额外的 " 引号:

// get your api call
def myApiCall = context.testCase.getTestStepByName('myApiCall')
// get the raw response
def responseUrl = myApiCall.getPropertyValue('Response')
// since your response contains the `"` remove it
responseUrl = responseUrl.replace('"','')
// set the endpoint correctly
def httpCall = context.testCase.getTestStepByName('myHttpCall')
httpCall.setPropertyValue("endpoint",responseUrl)