Groovy web console

subscribe to the feed Subscribe
to this
site
3911 (via #groovywebconsole)
tweet this snippet Tweet
this
script

3911

Published 1 month ago by Zs with tags slurping
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.time.TimeCategory
import groovy.util.XmlSlurper
import groovy.util.slurpersupport.NodeChild
import groovy.xml.*

xml = '''<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="1395" MinorBuildNumber="0" Version="V2_23" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></s:Header><s:Body><m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><m:ResponseMessages><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage><m:FindItemResponseMessage ResponseClass="Error"><m:MessageText>Too many concurrent connections opened.</m:MessageText><m:ResponseCode>ErrorTooManyObjectsOpened</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey></m:FindItemResponseMessage></m:ResponseMessages></m:FindItemResponse></s:Body></s:Envelope>
'''

def rootNode = new XmlSlurper().parseText(xml)


if (!(rootNode.Body.FindItemResponse.ResponseMessages.FindItemResponseMessage.ResponseCode.text() == "NoError")) {

println "WOW, there is an ERROR here:"
println rootNode.Body.FindItemResponse.ResponseMessages.FindItemResponseMessage.ResponseCode.text()

}
else
{
println "All good, Guvnor!"
}