(MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
Message message = null;
if (value != null) {
Class providerType = getProviderType();
BlockFactory factory = createBlockFactory(providerType);
if (value instanceof XMLFault) {
if (log.isDebugEnabled()) {
log.debug("Creating message from XMLFault");
}
message = msgFactory.create(protocol);
message.setXMLFault((XMLFault)value);
} else if (mode != null && mode == Service.Mode.MESSAGE) {
// For MESSAGE mode, work with the entire message, Headers and Body
// This is based on logic in org.apache.axis2.jaxws.client.XMLDispatch.createMessageFromBundle()
if (value instanceof SOAPMessage) {
if (log.isDebugEnabled()) {
log.debug("Creating message from SOAPMessage");
}
message = msgFactory.createFrom((SOAPMessage)value);
} else if (value instanceof SOAPEnvelope) {
// The value from the provider is already an SOAPEnvelope OMElement, so
// it doesn't need to be parsed into one.
if (log.isDebugEnabled()) {
log.debug("Creating message from OMElement");
}
message = msgFactory.createFrom((SOAPEnvelope) value, protocol);
} else {
if (log.isDebugEnabled()) {
log.debug("Creating message using " + factory);
}
Block block = factory.createFrom(value, null, null);
message = msgFactory.createFrom(block, null, protocol);
}
} else {
// PAYLOAD mode deals only with the body of the message.
if (log.isDebugEnabled()) {
log.debug("Creating message (payload) using " + factory);
}
Block block = factory.createFrom(value, null, null);
message = msgFactory.create(protocol);
if (XMLFaultUtils.containsFault(block)) {
if (log.isDebugEnabled()) {
log.debug("The response block created contained a fault. Converting to an XMLFault object.");