MessageReader typeReader = reader.getAttributeReader( XSI_TYPE );
if( null == typeReader && !readToDocument )
{
throw new XFireFault( "Missing 'xsi:type' attribute", XFireFault.SENDER );
}
String typeName = typeReader.getValue();
if( null == typeName && !readToDocument )
{
throw new XFireFault( "Missing 'xsi:type' attribute value", XFireFault.SENDER);
}
Type type = null;
QName typeQName = null;
if (typeName != null)
{
typeQName = extractQName(reader, typeName);
}
else
{
typeQName = reader.getName();
}
TypeMapping tm = (TypeMapping) context.getService().getProperty(AegisBindingProvider.TYPE_MAPPING_KEY);
if (tm == null)
{
tm = getTypeMapping();
}
type = tm.getType( typeQName );
if (type == null)
{
type = tm.getType(getSchemaType());
}
if (type == null && readToDocument)
{
type = getTypeMapping().getType(Document.class);
}
if( null == type )
{
//TODO should check namespace as well..
if( serializedWhenUnknown && "serializedJavaObject".equals( typeName ) )
{
return reconstituteJavaObject( reader );
}
throw new XFireFault( "No mapped type for '" + typeName + "' (" + typeQName + ")", XFireFault.SENDER);
}
return type.readObject( reader, context );
}