You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jesper Söderlund <Je...@smarttrust.com> on 2002/05/17 10:46:10 UTC

SOAP messages - problems with text nodes

I want to produce a SOAP-message body that looks something like this:
 
<e:operationX xmlns:e="urn:ABC"=>
    <info1>
        <subinfo11>qwerty</subinfo11>
        <subinfo12>123456</subinfo12>
    </info1>
    <info2>
        <subinfo21>78980</subinfo21>
        <subinfo22>ytrewq</subinfo22>
    </info2>
</operationX>
 
I seem to have a hard time constructing this using Axis Beta2 and the org.apache.axis.message.* and related classes.
 
Since both the operation and the info + subinfo elements are in the same namespace I don't want to repeat the NS-declarations.
So I tried to do something like this:
 
SOAPEnvelope env = SOAPEnvelope(false, SOAPConstants.SOAP11_CONSTANTS);
SOAPBodyElement info1 = new SOAPBodyElement("urn:ABC", "info1", "e");
SOAPElement subinfo11 = info1.addChildElement("subinfo1");
 
Now I have the subinfo11 element and want to add the "qwerty" value to this element but I cannot find a way to do this since the "addTextNode" is not supported.
OK so I can create an Element as a text node, but what do I do with this text node? I must somehow get it to become a SOAPElement so that I can do "subinfo11.addChildElement(aSOAPElement)". The way to do this seems to be to instantiate a "MessageElement" and pass some values in the constructor, but the constructor taking an "Element" is package scope so that doesn't work.
 
An ugly workaround would be (I guess) to build the whole "info1" as an "Element" and add it to the constructor of SOAPBodyElement().
 
Is there some obvious way that I'm missing?
 
It feels like the natural solution would be to support the "addTextNode" method.
 
Thanks,
/Jesper