axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Green-Lank (JIRA)" <>
Subject [jira] [Commented] (AXIS2-5071) Failure to populate all members of an xs:sequence in a SOAP header
Date Fri, 10 Jun 2011 17:11:59 GMT


David Green-Lank commented on AXIS2-5071:

After spending some time getting the AXIS source code and debugging this, I have narrowed
it down to the following code in Stub#addHeader():

        OMNode omNode = null;

        // add child elements
        for (Iterator iter = omElementToadd.getChildren(); iter.hasNext();){
             omNode = (OMNode); // after this line executes, iter.hasNext() returns
             soapHeaderBlock.addChild(omNode); // after this line executes, iter.hasNext()
returns false

So adding the omNode to the SOAP header causes a side effect on the iterator, and the <password>
element is never added.

My guess is that when an omNode is added to a new parent, it's removed from the old parent,
and therefore, when the <username> element is added to the header, the <password>
element shifts to position #0, and therefore iter.hasNext() returns false since there is no
child at index 1 anymore. But that's just a guess, I didn't download the axiom source code.

The following replacement code resolves the issue:

        // add child elements. make a safe copy first, since adding the OMNode to the SOAP
envelope causes a side
        // effect on the iterator
        List<OMNode> nodesToAdd = new ArrayList<OMNode>();
        for (Iterator iter = omElementToadd.getChildren(); iter.hasNext();){
            OMNode omNode = (OMNode);
            nodesToAdd.add( omNode );
        for ( OMNode omNode : nodesToAdd ) {
            soapHeaderBlock.addChild( omNode );

> Failure to populate all members of an xs:sequence in a SOAP header
> ------------------------------------------------------------------
>                 Key: AXIS2-5071
>                 URL:
>             Project: Axis2
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>         Environment: MacOSX Leopard, Apache AXIS 1.6.0, Java 1.6.0_24
>            Reporter: David Green-Lank
>         Attachments: Screen shot 2011-06-10 at 8.11.15 AM.png, mytest.wsdl
> There is a soap header declared in the wsdl that points to an element:
>       <xs:element name="authentication">
>         <xs:complexType>
>           <xs:sequence>
>             <xs:element name="username" type="xs:string"/>
>             <xs:element name="password" type="xs:string"/>
>           </xs:sequence>
>           <xs:anyAttribute namespace="##other"/>
>         </xs:complexType>
>       </xs:element>
> After running "sh -uri <uri>" to create stubs, and I populate that
element with:
>     MyTestServiceStub stub = new MyTestServiceStub();
>     MyTestServiceStub.Authentication auth = new MyTestServiceStub.Authentication();
>     auth.setUsername( "username" );
>     auth.setPassword( "password" );
>     stub.operation( new MyTestServiceStub.Operation(), auth, null );
> The following SOAP envelope is sent:
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=""><soapenv:Header><ns1:authentication
xmlns:ns1="urn:mytest" soapenv:mustUnderstand="false"><ns1:username>username</ns1:username></ns1:authentication></soapenv:Header><soapenv:Body><ns1:operation
xmlns:ns1="urn:mytest" /></soapenv:Body></soapenv:Envelope>
> Notice the supplied password element is missing.
> Screenshot attached.

This message is automatically generated by JIRA.
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message