header
header
Main Menu
Home
Eviware Store
Downloads
Products
News
Forum
Eviware Blog
Search
FAQs
Customer Area
Support
Documentation
Tutorials
CookBook
Downloads
Forum
Login Form
Welcome, Guest. Please login or register.
November 22, 2008, 01:36:19 pm
Username: Password:
Login with username, password and session length

Forgot your password?
 
SOAP XML Parsing with Groovy.
Welcome, Guest. Please login or register.
November 22, 2008, 01:36:19 pm
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  SOAP XML Parsing with Groovy.
« previous next »
Pages: [1] Print
Author Topic: SOAP XML Parsing with Groovy.  (Read 508 times)
ind
Newbie
*
Posts: 6


« on: July 27, 2007, 10:31:34 am »

Hi,

Here is my SOAP Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
   <soapenv:Header/>
   <soapenv:Body>
      <web:GetUKLocationByPostCode>
         <!--Optional:-->
         <web:PostCode>33</web:PostCode>
    <web:county>Manipal</web:county>
      </web:GetUKLocationByPostCode>
   </soapenv:Body>
</soapenv:Envelope



// //I need to get the  Postcode value/text.so here is my  Groovy Snippet To get the  Postcode  Text /Value ..But it didn't work...Because Of the  presence of    ":".



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

rootNode.each {
  output += it.text().trim()
}
log.info(output)
log.info(rootNode.soapenv:Envelope.soapenv:Header.soapenv:Body.web:GetUKLocationByPostCode.web:PostCode.text())

But the same  code works fine with the Normal XML (i.e, Doesn't contain ":" ).
So, how to get  the Postcode.

Regards,
Franky.
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #1 on: July 27, 2007, 11:16:45 am »

Hi Franky,

have a look at the "Modification of request xml" example in our user-guide at http://www.soapui.org/userguide/functional/groovystep.html#Groovy_Script_Examples, it shows how to parse a message containing namespaces..

Alternatively go for the soapUI Pro version which contains a GroovyUtils class that makes this even easier.. check out http://www.soapui.org/userguide/functional/groovystep.html#GroovyUtils

regards!

/Ole
eviware.com
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
header header
header
header