You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Lorenzo (JIRA)" <ji...@apache.org> on 2007/10/03 11:01:13 UTC

[jira] Issue Comment Edited: (AXIS2-3240) SAAJ : Problems when adding values

    [ https://issues.apache.org/jira/browse/AXIS2-3240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12532041 ] 

cencio edited comment on AXIS2-3240 at 10/3/07 2:00 AM:
---------------------------------------------------------

This may help more:

i build this Element

-------------------------------------------
CODE
-------------------------------------------

Name name = new PrefixedQName(Costanti.NAMESPACE_EGOV,"Intestazione",Costanti.PREFIX_EGOV);

SOAPFactoryImpl sf = new SOAPFactoryImpl();
sf.setSOAPVersion(SOAPConstants.SOAP_1_1_PROTOCOL);

SOAPElementImpl eGovHeader = (SOAPElementImpl) sf.createElement(name);

eGovHeader.addNamespaceDeclaration("SOAP_ENV","http://schemas.xmlsoap.org/soap/envelope/");
eGovHeader.addAttribute(new QName("http://schemas.xmlsoap.org/soap/envelope/",Constants.ATTR_ACTOR,"SOAP_ENV"), Costanti.ACTOR_EGOV);
eGovHeader.addAttribute(new QName("http://schemas.xmlsoap.org/soap/envelope/",Constants.ATTR_MUST_UNDERSTAND,"SOAP_ENV"), "true");

// Then add many children element with .addChildElement(String localName);

------------------------------------------------
END CODE.
------------------------------------------------

Now, if i add this node to my SOAPHeader with this:

SOAPElement o = hdr.addChildElement(headerEGovElement);

I have added just that node without childs, namespaces and attributes... 

for(Iterator i = headerEGovElement.getChildElements();i.hasNext();){
        o.addChildElement((SOAPElement)i.next());
}

Now  i get the header with all childs, but i loose the SOAP_ENV namespace and mustUnderstand and  actor attributes from the first child.

seems that something is wrong only with the first element... maybe something is wrong with the factory ?




      was (Author: cencio):
    This may help more:

i build this Element

-------------------------------------------
CODE
-------------------------------------------

Name name = new PrefixedQName(Costanti.NAMESPACE_EGOV,"Intestazione",Costanti.PREFIX_EGOV);

SOAPFactoryImpl sf = new SOAPFactoryImpl();
sf.setSOAPVersion(SOAPConstants.SOAP_1_1_PROTOCOL);

SOAPElementImpl eGovHeader = (SOAPElementImpl) sf.createElement(name);

eGovHeader.addNamespaceDeclaration("SOAP_ENV","http://schemas.xmlsoap.org/soap/envelope/");
eGovHeader.addAttribute(new QName("http://schemas.xmlsoap.org/soap/envelope/",Constants.ATTR_ACTOR,"SOAP_ENV"), Costanti.ACTOR_EGOV);
eGovHeader.addAttribute(new QName("http://schemas.xmlsoap.org/soap/envelope/",Constants.ATTR_MUST_UNDERSTAND,"SOAP_ENV"), "true");

// Then add many children element with .addChildElement(String localName);

------------------------------------------------
END CODE.
------------------------------------------------

Now, if i add this node to my SOAPHeader with this:

SOAPElement o = hdr.addChildElement(headerEGovElement);

I have added just that node without childs, namespaces and attributes... 

for(Iterator i = headerEGovElement.getChildElements();i.hasNext();){
        o.addChildElement((SOAPElement)i.next());
}

Now  i get the header with all childs, but i loose the SOAP_ENV namespace and mustUnderstand and  actor attributes from the first child.

seems that something is wrong only with the first element... maybe something is wrong with the builder?



  
> SAAJ : Problems when adding values
> ----------------------------------
>
>                 Key: AXIS2-3240
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3240
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.3
>            Reporter: Lorenzo
>            Assignee: sumedha rubasinghe
>
> 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)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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