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

Marco Benuzzi commented on AXIS2-5135:
--------------------------------------

My workaround for the problem is to modify addHeader method as follow

    protected void addHeader(OMElement omElementToadd,
                             SOAPEnvelope envelop,
                             boolean mustUnderstand){
        SOAPHeaderBlock soapHeaderBlock =
                
envelop.getHeader().addHeaderBlock(omElementToadd.getLocalName(),omElementToadd.getNamespace());
        soapHeaderBlock.setMustUnderstand(mustUnderstand);
        OMNode omNode = null;

        // add child elements
        List<OMNode> temp = new ArrayList<OMNode>();
        for (Iterator iter = omElementToadd.getChildren(); iter.hasNext();) {
             omNode = (OMNode) iter.next();
             temp.add(omNode);
        }
        for (OMNode n : temp ) {
             soapHeaderBlock.addChild(n);
        }

        OMAttribute omatribute = null;
        // add attributes
        for (Iterator iter = omElementToadd.getAllAttributes(); 
iter.hasNext();) {
             omatribute = (OMAttribute) iter.next();
             soapHeaderBlock.addAttribute(omatribute);
        }

    }



> only the first child is copied in header element
> ------------------------------------------------
>
>                 Key: AXIS2-5135
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5135
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb, kernel
>    Affects Versions: 1.6.0
>         Environment: Linux 2.6.35.14-95.fc14.i686.PAE
> Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
>            Reporter: Marco Benuzzi
>            Priority: Blocker
>
> In my wsdl I've the following message:
>     <wsdl:operation name="Security_Authenticate">
>       <soap:operation soapAction="http://xxxxxxxxxxxxxxxxxxx"/>
>       <wsdl:input>
>         <soap:header message="aws:Session" part="Session" use="literal"/>
>         <soap:body use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:header message="aws:Session" part="Session" use="literal"/>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
> The Session type used in the header is defined as follow:
>       <xs:element name="Session">
>               <xs:complexType>
>                       <xs:sequence>
>                               <xs:element name="SessionId" type="xs:string">
>                                       <xs:annotation>
>                                               <xs:documentation>This element 
> defines the identifier part of the SessionId.</xs:documentation>
>                                       </xs:annotation>
>                               </xs:element>
>                               <xs:element name="SequenceNumber" 
> type="xs:string">
>                                       <xs:annotation>
>                                               <xs:documentation>This element 
> defines the sequence number of the SessionId.</xs:documentation>
>                                       </xs:annotation>
>                               </xs:element>
>                               <xs:element name="SecurityToken" 
> type="xs:string">
>                                       <xs:annotation>
>                                               <xs:documentation>This element 
> defines the SecurityToken of the SessionId.</xs:documentation>
>                                       </xs:annotation>
>                               </xs:element>
>                       </xs:sequence>
>               </xs:complexType>
>       </xs:element>
> I'm using adb binding.
> The actual soap message generated is
> <?xml version='1.0' encoding='UTF-8'?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
>   <soapenv:Header>
>     <ns1:Session xmlns:ns1="http://xxxxxxxxxxxxx.xsd"; 
> soapenv:mustUnderstand="0">
>       <ns1:SessionId>xxxxx</ns1:SessionId>
>     </ns1:Session>
>   </soapenv:Header>
>   <soapenv:Body>
>     <ns38:Security_Authenticate xmlns:ns38="........
> The Session element in the header is wrong because are missing two childs 
> SequenceNumber and SecurityToken
> I had a look on the sources for axis2 and axiom and, in my opinion, the 
> problem is in the method org.apache.axis2.client.Stub.addHeader()
>     protected void addHeader(OMElement omElementToadd,
>                              SOAPEnvelope envelop,
>                              boolean mustUnderstand){
>         SOAPHeaderBlock soapHeaderBlock =
>                 
> envelop.getHeader().addHeaderBlock(omElementToadd.getLocalName(),omElementToadd.getNamespace());
>         soapHeaderBlock.setMustUnderstand(mustUnderstand);
>         OMNode omNode = null;
>         // add child elements
>         for (Iterator iter = omElementToadd.getChildren(); iter.hasNext();){
>              omNode = (OMNode) iter.next();
>              soapHeaderBlock.addChild(omNode.cloneOMElement());
> /**
> PROBLEM HERE
> soapHeaderBlock.addChild changes the parent of omNode which is the current 
> element of iter
> when iter.hasNext() is executed it use the parent of its current element to 
> find the next one
> but the current element parent is changed (the parent is soapHeaderBlock 
> instead of omElementToadd)
> PS: if you use axiom-1.2.12 you got a ConcurrentModificationException in the 
> above code!!!!
> **/
>         }
>         OMAttribute omatribute = null;
>         // add attributes
>         for (Iterator iter = omElementToadd.getAllAttributes(); 
> iter.hasNext();){
>              omatribute = (OMAttribute) iter.next();
>              soapHeaderBlock.addAttribute(omatribute);
>         }
>     }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to