DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15208>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15208

calling getChildElements(name) on SOAPBody - classCastException

           Summary: calling getChildElements(name) on SOAPBody -
                    classCastException
           Product: Axis
           Version: 1.0
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Basic Architecture
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


If call getChildElements(name) on a SOAPBody your receive a class cast 
exception, I'm not an Axis developer but I took a peek at the latest source 
code and there seems to be cut/paste error for the same method of SOAPHeader 
and SOAPBodyElements are mis-casted to SOAPHeaderElements any here's some 
sample code to replicate:

import java.util.Iterator;
import javax.xml.soap.*;

public class ClassCastExceptionTest
{
    public static void main(String[] args) throws Exception 
    {
        MessageFactory factory = MessageFactory.newInstance ();
        SOAPMessage message = factory.createMessage ();
        
        // Traverse the message and get to the SOAP Body
        SOAPPart soapPart = message.getSOAPPart ();
        SOAPEnvelope envelope = soapPart.getEnvelope ();
        SOAPBody body = envelope.getBody ();
        
        Name myName = envelope.createName ("MyName");
        body.addBodyElement(myName);
                
        try
        {   
            Iterator it = body.getChildElements (myName);    // <---- the 
offending code is in here
            if (it.hasNext ())
                System.out.println ("There are child elements");
        }
        catch (ClassCastException clc)
        {
            System.err.println ("Surely this ClassCastException exception is 
caused by a bug?");
        }
    }
}

Reply via email to