Is it possible to manipulate a soap envelope element?

Viewed 56
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://someuri/">
    <soapenv:Header/>
        <soap:Body>
            <Element>
                ///
            </Element>
            <Element>
                ///
            </Element>
        </soap:Body>
</soap:Envelope>

Hello

i need to change the uri in [xmlns:api="http://someuri/"] in the envelope element to "someotheruri" with a GroovyScript.

I searched for hours how to use xmlslurper, xmlparser and every node would be easily changeable. But i need to change this namespace that is in the rootelement.

def source = new File("test.xml").text

    def root = new XmlSlurper(false, false).parseText(source)
    println(root.lookupNamespace("api"))

It give me the uri as a String but not the node of it. Do i missing something?

It is really late and now my last hope is to ask here.

Thanks in advance!

1 Answers

The project file is an XML. You can do a replaceAll() on the project file outside of SoapUI:

def projectFileA = new File('/path/to/your/soapui-project.xml')
def projectFileB = projectFileA.text.replaceAll('xmlns:api="http://someuri/"', 'xmlns:api="http://someotheruri/"')
projectfileA.text = projectfileB
Related