groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deng, Lea" <Lea.D...@ccc.govt.nz>
Subject RE: retrieving a node with XmlSlurper gives empty string in SoapUI
Date Mon, 11 Jan 2016 03:42:22 GMT
Hi Paul,
Thank you very much for your suggestion. 
I still get empty string back for these code:

def decisionCode =response.'s:Body'.GetPathwayLimReportDataResponse.GetPathwayLimReportDataResult.'a:ConsentApplicationEntity'.'a:DecisionList'.'a:DecisionEntity'.'a:Decisioncode'[0]

Or:

def decisionCode =response.Body.GetPathwayLimReportDataResponse.GetPathwayLimReportDataResult.ConsentApplicationEntity.DecisionList.DecisionEntity.Decisioncode[0]


Thanks, 
lea
-----Original Message-----
From: Strachan, Paul [mailto:Paul.Strachan@det.nsw.edu.au] 
Sent: Monday, 11 January 2016 4:31 p.m.
To: users@groovy.apache.org
Subject: RE: retrieving a node with XmlSlurper gives empty string in SoapUI

Try:
def decisionCode = response.Body.GetPathwayLimReportDataResponse.GetPathwayLimReportDataResult.ConsentApplicationEntity.DecisionList.DecisionEntity.DecisionCode[0]


From: Deng, Lea [mailto:Lea.Deng@ccc.govt.nz]
Sent: Monday, 11 January 2016 11:38 AM
To: users@groovy.apache.org
Subject: retrieving a node with XmlSlurper gives empty string in SoapUI

Hi,
I've been trying to retrieve a node "DecisionCode" from a xml format record in SoapUI framework.

I've added name space declaration but the decisionCode returned is an empty string.
I suspect SoapUI does not support XmlSlurper well?
Any suggestion is appreciated. 
Many thanks,
lea
 
 
 
def response = new XmlSlurper().parseText(records).declareNamespace('s':'http://schemas.xmlsoap.org/soap/envelope/','xmlns':'http://schemas.datacontract.org/2004/07/ABC.Framework.Global.Entity',
'a':'http://schemas.datacontract.org/2004/07/ABC.BusinessService.LimReport.ServiceContract.Entity','i':'http://www.w3.org/2001/XMLSchema-instance')
 
 
def decisionCode =response.GetPathwayLimReportDataResponse[0].GetPathwayLimReportDataResult[0].'a:ConsentApplicationEntity'[0].'a:DecisionList'[0].'a:DecisionEntity'[0].'a:Decisioncode'[0]
 
below is a sample returned xml record
--------------------------------------------------------------------------------------------------------------------------------------------
def records = '''
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <GetPathwayLimReportDataResponse xmlns="http://tempuri.org/">
         <GetPathwayLimReportDataResult xmlns:a="http://schemas.datacontract.org/2004/07/ABC.BusinessService.LimReport.ServiceContract.Entity"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:ConsentApplicationEntity>
               <ID xmlns="http://schemas.datacontract.org/2004/07/ABC.Framework.Global.Entity">123456</ID>
               <ObjectStatus xmlns="http://schemas.datacontract.org/2004/07/ABC.Framework.Global.Entity">IsClean</ObjectStatus>
               <a:Amendment i:nil="true"/>
               <a:ApplicantID i:nil="true"/>
               <a:ApplicationClass>BCN</a:ApplicationClass>
               <a:ApplicationDate>1965-07-12T00:00:00</a:ApplicationDate>
               <a:ApplicationNumber>1965/3637</a:ApplicationNumber>
               <a:ApplicationStatusCode>COMPLT</a:ApplicationStatusCode>
               <a:ApplicationStatusDesc>Completed</a:ApplicationStatusDesc>
               <a:ApplicationTypeCode>PERMIT</a:ApplicationTypeCode>
               <a:ApplicationTypeDesc>Permit</a:ApplicationTypeDesc>
               <a:BuildingName>64 Clarence Street Addington</a:BuildingName>
               <a:Conditions i:nil="true"/>
               <a:ConsentCategory>
                  <a:CategoryEntity>
                     <a:CategoryDescription>VAX converted record</a:CategoryDescription>
                     <a:CategoryType>CONVAX</a:CategoryType>
                  </a:CategoryEntity>
                  <a:CategoryEntity>
                     <a:CategoryDescription>Permit</a:CategoryDescription>
                     <a:CategoryType>PERMIT</a:CategoryType>
                  </a:CategoryEntity>
               </a:ConsentCategory>
               <a:DecisionList>
                  <a:DecisionEntity>
                     <a:DecisionCode>BCOACC</a:DecisionCode>
                     <a:DecisionDate>1965-07-12T00:00:00</a:DecisionDate>
                     <a:DecisionText>Accepted for processing</a:DecisionText>
                     <a:EffectiveDate>1965-07-12T00:00:00</a:EffectiveDate>
                  </a:DecisionEntity>
                  <a:DecisionEntity>
                     <a:DecisionCode>PERGRN</a:DecisionCode>
                     <a:DecisionDate>1965-07-20T00:00:00</a:DecisionDate>
                     <a:DecisionText>Permit granted</a:DecisionText>
                     <a:EffectiveDate>1965-07-20T00:00:00</a:EffectiveDate>
                  </a:DecisionEntity>
                  <a:DecisionEntity>
                     <a:DecisionCode>PERISS</a:DecisionCode>
                     <a:DecisionDate>1965-07-20T00:00:00</a:DecisionDate>
                     <a:DecisionText>Permit issued</a:DecisionText>
                     <a:EffectiveDate>1965-07-20T00:00:00</a:EffectiveDate>
                  </a:DecisionEntity>
               </a:DecisionList>
               <a:Description>ERECT A FACTORY- Historical Reference PER651111</a:Description>
               <a:EstimatedCost>0.000000</a:EstimatedCost>
               <a:FormattedApplicationNumber>BCN/1965/3637</a:FormattedApplicationNumber>
               <a:HasSolarWater>false</a:HasSolarWater>
               <a:InterestedParties>
                  <a:ContactEntity>
                     <a:ConsentContactType>Other</a:ConsentContactType>
                     <a:EmailAddress i:nil="true"/>
                     <a:FaxNumber i:nil="true"/>
                     <a:FormattedAddress i:nil="true"/>
                     <a:FormattedName>NT Property Limited</a:FormattedName>
                     <a:GivenNames i:nil="true"/>
                     <a:MobileNumber i:nil="true"/>
                     <a:PhoneNumber i:nil="true"/>
                     <a:Surname i:nil="true"/>
                  </a:ContactEntity>
               </a:InterestedParties>
               <a:LodgementDate>1965-07-12T00:00:00</a:LodgementDate>
               <a:Notes i:nil="true"/>
               <a:RestrictedBuildingWork>false</a:RestrictedBuildingWork>
               <a:Stage i:nil="true"/>
            </a:ConsentApplicationEntity>
 
         </GetPathwayLimReportDataResult>
      </GetPathwayLimReportDataResponse>
   </s:Body>
</s:Envelope>
'''
 
 
 
 
 
**********************************************************************
This electronic email and any files transmitted with it are intended solely for the use of
the individual or entity to whom they are addressed.
The views expressed in this message are those of the individual sender and may not necessarily
reflect the views of the Christchurch City Council.
If you are not the correct recipient of this email please advise the sender and delete.
Christchurch City Council
http://www.ccc.govt.nz
**********************************************************************
**********************************************************************
This message is intended for the addressee named and may contain privileged information or
confidential information or both. If you are not the intended recipient please delete it and
notify the sender.
**********************************************************************
**********************************************************************
This electronic email and any files transmitted with it are intended
solely for the use of the individual or entity to whom they are addressed.

The views expressed in this message are those of the individual sender
and may not necessarily reflect the views of the Christchurch City Council.

If you are not the correct recipient of this email please advise the
sender and delete.

Christchurch City Council
http://www.ccc.govt.nz
**********************************************************************

Mime
View raw message