Forum Discussion

chihhsiw's avatar
chihhsiw
Occasional Contributor
14 years ago

How do I get endpoint from a XML file?

Hello,
I want to get endpoint from an input file and I have input file data_source_file.txt

<ThreadCount>1</ThreadCount>
<endpoint>http://foo.bar</endpoint>

then in soapUI testcase I have

setup script

File readFile = new File(readfilePath+ "data_source_file.txt")
Filecontent = readFile.getText()

gutils = new com.eviware.soapui.support.GroovyUtils( context )

InputXML = gutils.getXmlHolder(Filecontent)

when I run the testcase, I got the error below from getXmlHolder()
TestCase failed [org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA&colon;org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA], time taken = 0

If I remove <endpoint>http://foo.bar</endpoint>, then it is fine,

can anyone give me idea on how to fix this issue?

thanks

chihhsiw
  • Aaronliu's avatar
    Aaronliu
    Frequent Contributor
    Hi chihhsiw,

    you can try it again and run scripts separately:

    def path = "C:/myFolder/"
    def readFile = new File(path+"1325243405745.txt")
    def content = readFile.getText()
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
    def inputXml = groovyUtils.getXmlHolder(content)
    log.info inputXml.getPrettyXml()


    see if it's helpful
    thanks,
    Aaron