SOLVED-Trying to get the SAML <Assertion> element from a response to Transfer property
Hi,
I am trying to get the signed SAML <Assertion> element from a response to one test step in one test case into a Transfer property, so that I can inject that assertion into the body of a request in a test step in another test case.
I am actually able to successfully ALMOST do that, but the problem I am running into is that the <Assertion> that I extracted appears to be stripped of all new lines, so the extracted <Assertion> is no longer valid, because the signature fails.
I have tried several ways so far, but no success:
- The straightforward approach - just putting a transfer property with the Xpath to find the <Assertion> - result was the transfer property had no new lines.
- Use a scripted assertion + transfer property - I used a scripted assertion to set a property:
def myVar = messageExchange.getResponseContentAsXml().toString()
log.info myVar
context.testCase.setPropertyValue('MSG_ID', myVar)
Then, I had the Xpath in a transfer property against the property 'MSG_ID'
Result was the same as the straightforward approach, i.e., new lines were gone from the transfer property.
Does anyone know how to make this work? From searching, this (getting the raw response) seems to be a fairly common problem/scenario, but is there actually a way to do this with SOAPUI?
Thanks,
Jim
EDIT: I am using SOAPUI 5.3.0
Hi,
Sort of answering my original question, the following in a groovy script step seems to be able to get the raw response:
def rawResponse = testRunner.testCase.testSteps["TC1 - NoAttribs"].testRequest.response.rawResponseData log.info new String(rawResponse)
However, the rawResponse has not just the XML I am interested in, but also the HTTP response headers, etc.:
Wed Apr 04 14:36:19 EDT 2018:INFO:HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Connection: close Content-Type: text/xml;charset=UTF-8 Content-Length: 4249 Date: Wed, 04 Apr 2018 18:31:13 GMT Connection: close <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> . . .
I now need to strip off that stuff to get the XML so that I can then parse it for the <saml2:Assertion> element. That's the next thing I need to figure out how to do :(...
Does anyone know of an easy way to do that with Groovy?
Thanks,
Jim