Ask a Question

read&Print soap response with Groovy script

SOLVED
babusr01
Contributor

read&Print soap response with Groovy script

Hi,

 

I am trying to the automate the  my requirement as read soap response and write it.

In groovy script , i am getting the response and need to read the ResponseHeader and list of the people form getlist

 

Below is the Sample Soap Response

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
<soapenv:Body>
<ns0:GetListBy_QualificationResponse xmlns:ns0="urn:WS_CTM_People_ICEVA">
<ResponseHeader>
<Status></Status>
<ErrorCode></ErrorCode>
<ErrorMessage></ErrorMessage>
</ResponseHeader>
<getList>
<get1>
<Person_ID>PPL000000301739</Person_ID>
<Submitter>soehler</Submitter>
</get1>
<get2>
<Person_ID>PPL000000301739</Person_ID>
<Submitter>soehler</Submitter>
</get2>
<get3>
<Person_ID>PPL000000301739</Person_ID>
<Submitter>soehler</Submitter>
</get3>
<get4>
<Person_ID>PPL000000301739</Person_ID>
<Submitter>soehler</Submitter>
</get4>
</getListValues>
<personStatus></personStatus>
</ns0:GetListBy_QualificationResponse>
</soapenv:Body>
</soapenv:Envelope>

2 REPLIES 2
nmrao
Community Hero

1. question desnot clearly says what specific details are needed

2. xml provided is not well-formed.

 

 

Here is the Script Assertion 

 

def response = context.response

assert response, 'response is empty or null'

def getData = { data, element ->
  def pXml = new XmlSlurper().parseText(data)
  def codes = pXml.'**'.findAll { it.name() == elegment}  
}

def submitters = getData(response, 'Submitter') as List<String>
log.info "Submitter values:  $submitters"

def getHeaderValue = { log.info "$it : ${getData($it)[0] as String}"}

getHeaderValue('Status')
getHeaderValue('ErrorCode')
getHeaderValue('ErrorMessage')


Regards,
Rao.

Hi Rao,

 

Sorry for delay for your response. finally i am able to  read and validate response.

I had good progress after couple your response.

cancel
Showing results for 
Search instead for 
Did you mean: