log.debug("getXMLFragment from Object [xmlType=" + xmlType + ",javaType=" + javaType + "]");
CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
if (msgContext == null)
throw new WSException("MessageContext not available");
SerializationContext serContext = msgContext.getSerializationContext();
serContext.setJavaType(javaType);
ParameterMetaData pmd = container.getParamMetaData();
OperationMetaData opMetaData = pmd.getOperationMetaData();
List<Class> registeredTypes = opMetaData.getEndpointMetaData().getRegisteredTypes();
serContext.setProperty(SerializationContextJAXWS.JAXB_CONTEXT_TYPES, registeredTypes.toArray(new Class[0]));
TypeMappingImpl typeMapping = serContext.getTypeMapping();
XMLFragment xmlFragment = null;
try
{
SerializerSupport ser;
if (objectValue != null)
{
AbstractSerializerFactory serializerFactory = getSerializerFactory(typeMapping, javaType, xmlType);
ser = (SerializerSupport)serializerFactory.getSerializer();
}
else
{
ser = new NullValueSerializer();
}
Result result = ser.serialize(container, serContext);
xmlFragment = new XMLFragment(result);
log.debug("xmlFragment: " + xmlFragment);
}
catch (BindingException e)
{
throw new WSException(e);
}
return xmlFragment;
}