Nicholas Palm created AXIS2-5508:
------------------------------------
Summary: parse method in New Fault extended from BaseFaultType
does not parse all data
Key: AXIS2-5508
URL: https://issues.apache.org/jira/browse/AXIS2-5508
Project: Axis2
Issue Type: Bug
Reporter: Nicholas Palm
When defining a new fault type extended from BaseFaultType, the XMLStreamReader
is not properly parsed in the parse method of the autogen new fault class. In
the 'while reader is not end element loop', there is an 'if reader is at start
element check'. Then followed by a few 'else if's' that parse for Timestamp,
Originator, ErrorCode, Description, and FaultCause. The problem is that the
these are 'else if' statements and will never be entered because they also
check to be a starting element, in which the initial if statement will already
catch. I have included the while loop below as well as the schema.
while(!reader.isEndElement()) {
if (reader.isStartElement() ){
if (reader.isStartElement()){
// Process the array and step past its final element's
end.
boolean loopDone1=false;
while (!loopDone1){
event = reader.getEventType();
if
(javax.xml.stream.XMLStreamConstants.START_ELEMENT == event){
// We need to wrap the reader so that
it produces a fake START_DOCUEMENT event
org.apache.axis2.databinding.utils.NamedStaxOMBuilder builder1 = new
org.apache.axis2.databinding.utils.NamedStaxOMBuilder(new
org.apache.axis2.util.StreamWrapper(reader), reader.getName());
list1.add(builder1.getOMElement());
reader.next();
if (reader.isEndElement()) {
// we have two countinuos end
elements
loopDone1 = true;
}
}else if
(javax.xml.stream.XMLStreamConstants.END_ELEMENT == event){
loopDone1 = true;
}else{
reader.next();
}
}
object.setExtraElement((org.apache.axiom.om.OMElement[])
org.apache.axis2.databinding.utils.ConverterUtil.convertToArray(org.apache.axiom.om.OMElement.class,list1));
} // End of if for expected property start element
else
if (reader.isStartElement() && new
javax.xml.namespace.QName("http://docs.oasis-open.org/wsrf/bf-2","Timestamp").equals(reader.getName())){
java.lang.String content = reader.getElementText();
object.setTimestamp(org.apache.axis2.databinding.utils.ConverterUtil.convertToDateTime(content));
reader.next();
} // End of if for expected property start element
else
if (reader.isStartElement() && new
javax.xml.namespace.QName("http://docs.oasis-open.org/wsrf/bf-2","Originator").equals(reader.getName())){
object.setOriginator(autogen.addressing.EndpointReferenceType.Factory.parse(reader));
reader.next();
} // End of if for expected property start element
else
if (reader.isStartElement() && new
javax.xml.namespace.QName("http://docs.oasis-open.org/wsrf/bf-2","ErrorCode").equals(reader.getName())){
object.setErrorCode(autogen.bf2.ErrorCode_type0.Factory.parse(reader));
reader.next();
} // End of if for expected property start element
else
if (reader.isStartElement() && new
javax.xml.namespace.QName("http://docs.oasis-open.org/wsrf/bf-2","Description").equals(reader.getName())){
// Process the array and step past its final element's
end.
list5.add(autogen.bf2.Description_type0.Factory.parse(reader));
//loop until we find a start element that is not part
of this array
boolean loopDone5 = false;
while(!loopDone5){
// We should be at the end element, but make
sure
while (!reader.isEndElement())
reader.next();
// Step out of this element
reader.next();
// Step to next element event.
while (!reader.isStartElement() &&
!reader.isEndElement())
reader.next();
if (reader.isEndElement()){
//two continuous end elements means we
are exiting the xml structure
loopDone5 = true;
} else {
if (new
javax.xml.namespace.QName("http://docs.oasis-open.org/wsrf/bf-2","Description").equals(reader.getName())){
list5.add(autogen.bf2.Description_type0.Factory.parse(reader));
}else{
loopDone5 = true;
}
}
}
// call the converter utility to convert and set the
array
object.setDescription((autogen.bf2.Description_type0[])org.apache.axis2.databinding.utils.ConverterUtil.convertToArray(autogen.bf2.Description_type0.class,
list5));
} // End of if for expected property start element
else
if (reader.isStartElement() && new
javax.xml.namespace.QName("http://docs.oasis-open.org/wsrf/bf-2","FaultCause").equals(reader.getName())){
object.setFaultCause(autogen.bf2.FaultCause_type0.Factory.parse(reader));
reader.next();
} // End of if for expected property start element
else{
// A start element we are not expecting indicates an
invalid parameter was passed
throw new
org.apache.axis2.databinding.ADBException("Unexpected subelement " +
reader.getName());
}
} else {
reader.next();
}
} // end of while loop
The schema includes:
<xsd:element name="SomeFault" type="tns:SomeFaultType">
<xsd:annotation>
<xsd:documentation>
An annotation.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="SomeFaultType">
<xsd:annotation>
<xsd:documentation>
An annotation.
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="wsrf-bf:BaseFaultType" />
</xsd:complexContent>
</xsd:complexType>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
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]