Forum Discussion

babusr01's avatar
babusr01
Contributor
8 years ago

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>

  • 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.

  • nmrao's avatar
    nmrao
    Champion Level 3

    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')
    • babusr01's avatar
      babusr01
      Contributor

      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.