PStraszynski
14 years agoOccasional Contributor
missing namespace text in XML - please help!
Hi there
I'm struggling to get my groovy code to produce the XML code that i need for my SOAP request.
I've basically taken an existing request that works - then stripped out the data that I wish to modify and then tried to replace it with data that I wish to use. (Not sure of the best method - but i've opted to use a groovy script?).
My problems seem to be related to namespaces - in my case it is named 'v1'
My request has this as it's first line :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://xxxxxx.com/dsselect/ExtractionService/v1/">
My Groovy code contains this extract, I'm trying to add a new child element that contains the namespace 'v1' within the tag name:
holder.removeDomNodes("//v1:Identifiers/*") // deletes some nodes before trying to replace them
org.w3c.dom.Element newXML = xmlUtils.addChildElement(holder.getDomNode("//v1:Identifiers"), "v1:InstrumentIdentifier", "")
log.info "Update 2 : " + holder.getXml()
org.w3c.dom.Element newelement = xmlUtils.addChildElement(newXML, "v1:IdentifierValue", fields[1]);
//log.info "Update 3 : " + holder.getXml()
newelement = xmlUtils.addChildElement(newXML, "v1:IdentifierType", fields[0]);
BUT
when i examine the tags that are inserted into my request the string "v1:" is missing , instead i get
<InstrumentIdentifier>
<IdentifierValue>AXAF.PA</IdentifierValue>
<IdentifierType>RIC</IdentifierType>
</InstrumentIdentifier>
My request won't work without the "v1". Can anyone please help me work out how to resolve this problem?
Really appreciate it - i've been struggling all day on this one
Jo
I'm struggling to get my groovy code to produce the XML code that i need for my SOAP request.
I've basically taken an existing request that works - then stripped out the data that I wish to modify and then tried to replace it with data that I wish to use. (Not sure of the best method - but i've opted to use a groovy script?).
My problems seem to be related to namespaces - in my case it is named 'v1'
My request has this as it's first line :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://xxxxxx.com/dsselect/ExtractionService/v1/">
My Groovy code contains this extract, I'm trying to add a new child element that contains the namespace 'v1' within the tag name:
holder.removeDomNodes("//v1:Identifiers/*") // deletes some nodes before trying to replace them
org.w3c.dom.Element newXML = xmlUtils.addChildElement(holder.getDomNode("//v1:Identifiers"), "v1:InstrumentIdentifier", "")
log.info "Update 2 : " + holder.getXml()
org.w3c.dom.Element newelement = xmlUtils.addChildElement(newXML, "v1:IdentifierValue", fields[1]);
//log.info "Update 3 : " + holder.getXml()
newelement = xmlUtils.addChildElement(newXML, "v1:IdentifierType", fields[0]);
BUT
when i examine the tags that are inserted into my request the string "v1:" is missing , instead i get
<InstrumentIdentifier>
<IdentifierValue>AXAF.PA</IdentifierValue>
<IdentifierType>RIC</IdentifierType>
</InstrumentIdentifier>
My request won't work without the "v1". Can anyone please help me work out how to resolve this problem?
Really appreciate it - i've been struggling all day on this one

Jo