try {
Object value = null;
if (protocol == Protocol.rest) {
// The implementation of rest stores the rest xml inside a dummy soap 1.1 envelope.
// So use the get body block logic.
Block block = xmlPart.getBodyBlock(context, blockFactory);
if (block != null) {
value = block.getBusinessObject(true);
}
} else {
// Must be SOAP
if (blockFactory instanceof SOAPEnvelopeBlockFactory) {
value = getAsSOAPMessage();
} else {
// TODO: This doesn't seem right to me.
// We should not have an intermediate StringBlock.
// This is not performant. Scheu
OMElement messageOM = getAsOMElement();
String stringValue = messageOM.toString();
String soapNS =
(protocol == Protocol.soap11) ? SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE
: SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;
QName soapEnvQname = new QName(soapNS, "Envelope");
XMLStringBlockFactory stringFactory =
(XMLStringBlockFactory)
FactoryRegistry.getFactory(XMLStringBlockFactory.class);
Block stringBlock = stringFactory.createFrom(stringValue, null, soapEnvQname);
Block block = blockFactory.createFrom(stringBlock, context);
value = block.getBusinessObject(true);
}
}
return value;
} catch (Throwable e) {
throw ExceptionFactory.makeWebServiceException(e);