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 Lorenzo <ce...@gmail.com> on 2007/09/28 16:18:17 UTC

[AXIS2] SAAJ setValue problems

Hi all,

i working on messages with SAAJ and i encunter this problem.

When i edit an element (now adding childs to Header) seems that
something go wrong when i add values..

For example:
-----------------------------------------------
CODE:
-----------------------------------------------

Name name = new PrefixedQName("http://myNS","lName","prefix");
SOAPFactoryImpl sf = new SOAPFactoryImpl();
SOAPElementImpl myEle = (SOAPElementImpl) sf.createElement(name1);

SOAPElementImpl child1 = 
	(SOAPElementImpl)myEle.addChildElement("child1");

SOAPElementImpl child1_1 =
	(SOAPElementImpl)child1.addChildElement("child1_1");

SOAPElementImpl child2 = 
	(SOAPElementImpl) myEle.addChildElement("child2");

SOAPElementImpl child2_1 = 
	(SOAPElementImpl) child2.addChildElement("child2_1");
	
System.out.println("O -> " + XMLUtils.toOM(myEle));

child2_1.setValue("AAAA");

System.out.println("A -> " + XMLUtils.toOM(myEle));

child1_1.setValue("BBBB");

System.out.println("B -> " + XMLUtils.toOM(myEle));
			
myEle.addChildElement("NEW");
child2.addChildElement("NEW");
child1.addChildElement("NEW");

System.out.println("N -> " + XMLUtils.toOM(myEle));


-----------------------------------------------
OUTPUT:
-----------------------------------------------

16:06:30,669 INFO  [STDOUT] O -> <prefix:lName
xmlns:prefix="http://myNS"><child1><child1_1 /></child1><child2><child2_1 /></child2></prefix:lName>

16:06:30,672 INFO  [STDOUT] A -> <prefix:lName
xmlns:prefix="http://myNS"><child1><child1_1 /></child1><child2><child2_1>AAAA</child2_1></child2></prefix:lName>

16:06:30,674 INFO  [STDOUT] B -> <prefix:lName
xmlns:prefix="http://myNS"><child1><child1_1>BBBB</child1_1></child1></prefix:lName>

16:06:30,677 INFO  [STDOUT] N -> <prefix:lName
xmlns:prefix="http://myNS"><child1><child1_1>BBBB</child1_1></child1></prefix:lName>

------------------------------------------------

If i make:
Iterator itr = myEle.getChildElements();
while(itr.hasNext()){
 log.info(XMLUtils.toOM((SOAPElementImpl) itr.next()));
} 

i can iterate in all childs but they are affected by the same problem...
Same when i writeTo the SOAPMessage (all new nodes missed eccept the
first one)

Where i make mistake?

Other question, there is another way to get the string content of an
element until .getTextContent() is TODO?  XMLUtil.toOM is expensive? 


Thx for any help,
Lorenzo


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [AXIS2] SAAJ setValue problems

Posted by Cencio1980 <ce...@gmail.com>.
I found an old mail where this problem was found by another user... it's a
known bug? Should i open a jira?

Lorenzo


2007/9/28, Lorenzo <ce...@gmail.com>:
>
> Hi all,
>
> i working on messages with SAAJ and i encunter this problem.
>
> When i edit an element (now adding childs to Header) seems that
> something go wrong when i add values..
>
> For example:
> -----------------------------------------------
> CODE:
> -----------------------------------------------
>
> Name name = new PrefixedQName("http://myNS","lName","prefix");
> SOAPFactoryImpl sf = new SOAPFactoryImpl();
> SOAPElementImpl myEle = (SOAPElementImpl) sf.createElement(name1);
>
> SOAPElementImpl child1 =
>        (SOAPElementImpl)myEle.addChildElement("child1");
>
> SOAPElementImpl child1_1 =
>        (SOAPElementImpl)child1.addChildElement("child1_1");
>
> SOAPElementImpl child2 =
>        (SOAPElementImpl) myEle.addChildElement("child2");
>
> SOAPElementImpl child2_1 =
>        (SOAPElementImpl) child2.addChildElement("child2_1");
>
> System.out.println("O -> " + XMLUtils.toOM(myEle));
>
> child2_1.setValue("AAAA");
>
> System.out.println("A -> " + XMLUtils.toOM(myEle));
>
> child1_1.setValue("BBBB");
>
> System.out.println("B -> " + XMLUtils.toOM(myEle));
>
> myEle.addChildElement("NEW");
> child2.addChildElement("NEW");
> child1.addChildElement("NEW");
>
> System.out.println("N -> " + XMLUtils.toOM(myEle));
>
>
> -----------------------------------------------
> OUTPUT:
> -----------------------------------------------
>
> 16:06:30,669 INFO  [STDOUT] O -> <prefix:lName
> xmlns:prefix="http://myNS"><child1><child1_1 /></child1><child2><child2_1
> /></child2></prefix:lName>
>
> 16:06:30,672 INFO  [STDOUT] A -> <prefix:lName
> xmlns:prefix="http://myNS"><child1><child1_1
> /></child1><child2><child2_1>AAAA</child2_1></child2></prefix:lName>
>
> 16:06:30,674 INFO  [STDOUT] B -> <prefix:lName
> xmlns:prefix="http://myNS
> "><child1><child1_1>BBBB</child1_1></child1></prefix:lName>
>
> 16:06:30,677 INFO  [STDOUT] N -> <prefix:lName
> xmlns:prefix="http://myNS
> "><child1><child1_1>BBBB</child1_1></child1></prefix:lName>
>
> ------------------------------------------------
>
> If i make:
> Iterator itr = myEle.getChildElements();
> while(itr.hasNext()){
> log.info(XMLUtils.toOM((SOAPElementImpl) itr.next()));
> }
>
> i can iterate in all childs but they are affected by the same problem...
> Same when i writeTo the SOAPMessage (all new nodes missed eccept the
> first one)
>
> Where i make mistake?
>
> Other question, there is another way to get the string content of an
> element until .getTextContent() is TODO?  XMLUtil.toOM is expensive?
>
>
> Thx for any help,
> Lorenzo
>
>