On Wed, Apr 20, 2011 at 3:01 PM, Andreas Veithen
<[email protected]>wrote:
> Hiranya,
>
> The release notes for Axiom 1.2.11 have a link to a section in the
> user guide that explains why this occurs.
>
Thanks for the pointer Andreas. So I guess we cannot use the iterator for
this purpose anymore? I tried out the following bit of code and it seems to
work:
OMNode node =
envelope.getBody().cloneOMElement().getFirstOMChild();
while (node != null) {
OMNode nextNode = node.getNextOMSibling();
newEnvelope.getBody().addChild(node);
node = nextNode;
}
Is this the proper way to solve this problem?
Thanks,
Hiranya
> Andreas
>
> On Wed, Apr 20, 2011 at 11:22, Hiranya Jayathilaka <[email protected]>
> wrote:
> > Hi Devs,
> > The clone mediator is having some issues in the latest trunk (with Axiom
> > 1.2.11 to be precise). We use the following bit of code to clone the SOAP
> > envelope (in MessageHelper class):
> > Iterator itr =
> > envelope.getBody().cloneOMElement().getChildren();
> > while (itr.hasNext()) {
> > newEnvelope.getBody().addChild((OMNode) itr.next());
> > }
> > Now let's assume the following message:
> > <soapenv:Envelope xmlns:soapenv="
> http://schemas.xmlsoap.org/soap/envelope/"
> >>
> > <soapenv:Body>
> > <ser:echoString xmlns:ser="http://service.carbon.wso2.org">
> > <ser:s>Hello</ser:s>
> > </ser:echoString>
> > </soapenv:Body>
> > </soapenv:Envelope>
> > The child element iterator for this message, returned by the above code
> will
> > initially have 3 elements (1 OMElement for the echoString element and 2
> > OMText objects for the white spaces around it). Once we have attached the
> > first OMText to the new envelope, subsequent calls to hasNext method on
> the
> > iterator will start returning false. So the resulting cloned envelope
> will
> > only have a bit of white space in the SOAP body.
> > I can see that there are some changes in the OMAbstractIterator and
> > OMChildrenIterator between Axiom 1.2.8 and 1.2.11. I guess that's
> probably
> > what's causing this. So any idea how we can fix this? One easy solution
> is
> > to change the above code as follows:
> > Iterator itr =
> > envelope.getBody().cloneOMElement().getChildren();
> > while (itr.hasNext()) {
> > if (itr.next() instanceof OMText) {
> > continue; // ignore text elements for white
> spaces
> > }
> > newEnvelope.getBody().addChild((OMNode) itr.next());
> > }
> > Thanks
> > --
> > Hiranya Jayathilaka
> > Senior Software Engineer;
> > WSO2 Inc.; http://wso2.org
> > E-mail: [email protected]; Mobile: +94 77 633 3491
> > Blog: http://techfeast-hiranya.blogspot.com
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
Hiranya Jayathilaka
Senior Software Engineer;
WSO2 Inc.; http://wso2.org
E-mail: [email protected]; Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com