opferlamm
10 years agoNew Member
XMl Parse Problems
Hello,
im a Bloody Rookie with Soap and XML and i try to get some values out of an XML request using Groovy Script. Sadly it doesnt work the way i want.
Here is my Response:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <ns4:customerSnapshotResponse xmlns:ns4="http://webservice.coraltreesystems.com" xmlns:ns3="http://pojo.macroProcessor.zentive.com" xmlns:ns2="http://pojo.ssi.zentive.com" xmlns="com.zentive.webservice"> <ns4:out> <ns4:equipSnapshotList> <ns4:dataPairs> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">ITEM_NUMBER</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">4366666</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">SERIAL_NUMBER</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">11965066209921</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">MAC_ADDRESS</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">11965066209921</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">TX</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">0,000000000</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">RX</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">0,000000000</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">SNR</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">0,000000000</value> </entry> </ns4:dataPairs> </ns4:equipSnapshotList> <ns4:equipSnapshotList> <ns4:dataPairs> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">ITEM_NUMBER</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1888999</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">SERIAL_NUMBER</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">UAAP43513996</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">MAC_ADDRESS</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">647C349A5C9F</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">TX</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">42,800000000</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">RX</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">6,300000000</value> </entry> <entry> <key xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">SNR</key> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">36,600000000</value> </entry> </ns4:dataPairs> </ns4:equipSnapshotList> <ns4:success>true</ns4:success> <ns4:errors/> <ns4:transactionReference>?</ns4:transactionReference> <ns4:moreItems>false</ns4:moreItems> </ns4:out> </ns4:customerSnapshotResponse> </S:Body> </S:Envelope>
and this is the Script i got so far
def response = context.expand( '${Snapshot#Response#declare namespace ns4=\'http://webservice.coraltreesystems.com\'; //ns4:customerSnapshotResponse[1]}' ) def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder("response") log.info holder['//S:Envelope/S:Body/ns4:customerSnapshotResponse/ns4:out/ns4:equipSnapshotList/ns4:dataPairs/entry/key'] log.info holder['//S:Envelope/S:Body/ns4:customerSnapshotResponse/ns4:out/ns4:equipSnapshotList/ns4:dataPairs/entry/value']
Here ist the Result of my Script
Wed Apr 15 16:24:52 CEST 2015:INFO:[Ljava.lang.String;@29ec2f6c Wed Apr 15 16:24:52 CEST 2015:INFO:[Ljava.lang.String;@511d70f4
It would be Kind if anyone could help me and Excuse my Bad English