/*
* Create a Message object out of the value object that was returned.
*/
private Message createMessageFromValue(Object value) throws Exception {
MessageFactory msgFactory =
(MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
Message message = null;
if (value != null) {
BlockFactory factory = createBlockFactory(providerType);
if (value instanceof XMLFault) {
message = msgFactory.create(messageProtocol);
message.setXMLFault((XMLFault)value);
} else if (providerServiceMode != null && providerServiceMode == 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) {
message = msgFactory.createFrom((SOAPMessage)value);
} else {
Block block = factory.createFrom(value, null, null);
message = msgFactory.createFrom(block, null, messageProtocol);
}
} else {
// PAYLOAD mode deals only with the body of the message.
Block block = factory.createFrom(value, null, null);
message = msgFactory.create(messageProtocol);
message.setBodyBlock(block);
}
}
if (message == null)
// If we didn't create a message above (because there was no value), create one here
message = msgFactory.create(messageProtocol);
return message;
}