Forum Discussion
Hi Angie,
There's a few bits here....
I'm assuming you've fixed your original assertion. The one thing I was going to suggest was the value to pass into the XML Sluper.
You wrote....
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = context.expand( '${SOAPRequest#Response}' )
def requestHolder = groovyUtils.getXmlHolder( holder )
Whereas, I'd usually use....
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = context.expand( '${SOAPRequest#ResponseAsXml}' ) // This line has the change.
def requestHolder = groovyUtils.getXmlHolder( holder )
I thought this was the issue, then I re-read your latest response. The request does not look like XML. If it isn't XML then the slurper cannot work with it.
If this was me, the first thing I'd do is log the request and the raw request. E.g.
def request = context.expand( '${SOAPRequest#Request}' ) ;
log.info(request);
def rawRequest = context.expand( '${SOAPRequest#RawRequest}' ) ;
log.info(rawRequest);
I appreciate that this is not the solution, but it may get us a step or two towards that.
Hi.
I was using XmlSlurper, but I could not figure out how to update the request with my new values. I have an Excel spreadsheet that includes the name of the nodes (EX: issueTypeId) whose values I need to capture. I am able to pull the needed nodes from the response and save them as TestCase properties. The next step is to update a request with those values. I do not know the nodes in advance or how many, so I cannot use the regular soapUI property transfer method. I have XmlSlurper code that finds the nodes in the request, but then I am stuck.
def holder = context.expand( '${SOAPRequest#Request}' )
def slurper=new XmlSlurper( false, false, false )
def resq = slurper.parseText( holder )
def dataCnt=0
resq.'**'.findAll { it.name() == nodeToUpdate } {
it.text()=propToUse[dataCnt]
dataCnt++
}
I know this all sounds crazy. Any ideas?
Thank you,
Angie
- ChrisAdams3 years agoChampion Level 3
Hi,
I think I know where you're going. Dynamic request based on response from earlier request. Not crazy or science fiction.
Is your second request payload XML or JSON? My idea would be the same for either, but you'd have to translate.
I'm going to have to make some assumptions, but I'll give an idea a go. By the way, you don't need property transfers.
Say your second (the dynamic) request is XML and the payload might be....
<ns1:someCustomerServiceRequest> <ns1:customerId>1001</ns1:customerId> </ns1:someCustomerServiceRequest>
Or....
<ns1:someCustomerServiceRequest> <ns1:customerSurname>Lennon</ns1:customerSurname> </ns1:someCustomerServiceRequest>
And it's the id or surname that is the changing bit in your test, you could change it to....
<ns1:someCustomerServiceRequest> ${Get Customer Service Payload - Groovy Script#result} </ns1:someCustomerServiceRequest>
This Groovy script called "Get Customer Service Payload - Groovy Script" must be in between service calls one and two.
In the Groovy script, implement the loop you built earlier, but for each value you want to pass to the second service, create the node of interest. E.g.
def nodeOfInterest = ${DataSource#NODEOFINTEREST} def valueOfInterest = "however you pull the value from the response of the first request." def node = "<ns1:${nodeOfInterest}>${valueOfInterest}</ns1:$nodeOfInterest>"; log.info(node) // Let's have a quick look at what we've built. return node; //This returns that value and will stick it in the second payload.