I have a log in request in soapUI and it returns a token in the response headers.

Using the groovy script:

       def value = testRunner.testCase.testSteps["Login"].testRequest.response.responseHeaders     ["Set-Cookie"]
   re = /(token=[A-Za-z0-9]+)/
          matcher = ( value =~ re )
        def loginToken = matcher[0][0]

           testRunner.testCase.setPropertyValue("Token", "$loginToken")

i have isolated the token but now i need to transfer that into a new request.

In the raw request line i have for this request i have:

Cookie: ASP.NET_SessionId=c4or1i45pfafgn55mwt0im45; ASPSESSIONIDQATCRRQQ=LCHPHGHDGCFKNABDBCHCBEBG; ASPSESSIONIDSAQCSRQQ=OICNPHKCGIMLOANJEIIDPIBG; FleetCommon=ReadOnly=0; FleetCustomerLogin=AutoRefresh=3&VehicleFilter=0&VehicleFilterName=&CanImport=True&IsSupervisor=True&UserName=Leaselink+Dev+1&HasOpMaint=2&FranchiseFilter=&CustomerID=161&CustomerName=ALD&EMail=leaselink%2Ddev%40ebbon%2Ddacs%2Ecom&UseLookupCodes=False&OperatorInitials=LD&ReadOnly=0&OperatorID=%7B952E5028%2D38A5%2D454B%2DB65B%2D686507C00B19%7D; FleetLogin=CSOptions=0&Operator=Leaselink+Dev+1&SystemSide=Lease&IsNominated=&ServiceView=False; LLMembership=B279E049D39450F12456020DAA66A06E8104ACC73DBBCCF9F15AC684462B0FC93E45E68B3D28F4CC2CACA9C1D58C0C7990793681C173958C316F4043DC5C1B315DDDE8CB158AEF90C674992E17A5586390D4606FC59EBE19E662682A3D7CBA7D32BA56F1A1DECAEA63F31A36DC452AD3DB7AEF9FC0F83A9929BD001C57ED9984A1D5EAA6A9243877D6A6279F1BE661B01F5B2A00B1B018EDE36AB1E8D4C7E8C2EC47C24D5656473C22BB11446309E8FB00000000; token=0FnAwkKNLyvQMVyAn2eljO0yyuzxWXNWlqaDcIeXgC8kdZng7vGw

This last bit:

 token=0FnAwkKNLyvQMVyAn2eljO0yyuzxWXNWlqaDcIeXgC8kdZng7vGw

I need to replace with my own value from the first response. That response currently sits as a property for the test case.

Any help would be appreciated.

Thanks in advance.

Adam

有帮助吗?

解决方案

Just in case anyone else is wondering I solved this issue by referencing where the property was in the testsuite.

I added a custom header of Cookie and set the value to:

{#Testcase#$Token}

I was overthinking it and when i'd read this previously i assumed "testcase" was meant to be the name of my testcase and was not literal.

Anyway thanks for helping!

Adam

其他提示

You can try the following

for (header in messageExchange.getResponseHeaders())
log.info header //<- prints all headers

I found this information on soapUI's forum

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top