Forum Discussion

liche's avatar
liche
Occasional Contributor
13 years ago

Parsing mq xml message

Hi,

I have some difficulties in parsing an mq xml message.

I have 4 test steps in my case (I follow what I find in the forum) :
1. A test request listening to queue (GetMsg)
2. A groovy script which parse the message received by the first step (TreatMsg)
3. A test request writing in a queue (SendMsg)
4. A groovy script which goes to step 1, to loop.

In my script (step 2) I have :
com.eviware.soapui.support.GroovyUtils
com.eviware.soapui.support.XmlHolder
def groovyUtils = new GroovyUtils(context)
def holder = groovyUtils.getXmlHolder('${GetMsg#Response}')


I have an error at the last line : "Unexpected element CDATA".
Have you an idea of the problem/solution ? (not getting the message from the first step or/and not using the good method)

Thanks for you help.

6 Replies

  • nmrao's avatar
    nmrao
    Community Hero
    Please see if this line works

    def holder = groovyUtils.getXmlHolder('GetMsg#Response')
  • liche's avatar
    liche
    Occasional Contributor
    Thanks Rao. I tired but I still have the same error with :

    def holder = groovyUtils.getXmlHolder('GetMsg#Response')
    def holder = groovyUtils.getXmlHolder('GetMsg#ResponseAsXml')
    def holder = groovyUtils.getXmlHolder('${GetMsg#ResponseAsXml}')
    def holder = groovyUtils.getXmlHolder("GetMsg#ResponseAsXml") (I found it here: viewtopic.php?t=3065)


    I tried also a property transfer which gets the input of the previous step and target a testCase temp variable I get in my groovy script step.
    I have the same error !
  • nmrao's avatar
    nmrao
    Community Hero
    Save the response in to xml file. And verify the response by opening in a browser if opens correctly?
  • liche's avatar
    liche
    Occasional Contributor
    I write the input message in a file :

    context.expand('${GetMsg#Response}') => store correctly the message
    context.expand('GetMsg#Response') => store GetMsg#Respone in the file
    context.expand("GetMsg#Response") => store GetMsg#Respone in the file

    What's working for the moment is
    def holder2 = new XmlSlurper().parseText(context.expand('${GetMsg#Response}'))


    I did not find a solution with getXmlHolder !
  • liche's avatar
    liche
    Occasional Contributor
    I have no error with the following code but also no result :

    def input = context.expand('${GetMsg#Response}')
    def holder = groovyUtils.getXmlHolder(input)
    log.info("Id: " + holder.getValueNode("//Id"))


    It returns : "Id: null"
    I can't get this node while with xmlSlurper, I succeed.