throw new IllegalStateException("No message context available for receiving message");
}
if (m_exchangeCtx.getCurrentMessageContext().isOutbound()) {
throw new IllegalStateException("Cannot receive message when current message context is outbound");
}
InContext context = (InContext) m_exchangeCtx.getCurrentMessageContext();
SoapReader soapReader = new SoapReader(conn);
try {
logger.debug("Starting receive message");
soapReader.startMessage();
IXMLReader xmlReader = soapReader.getReader();
if (soapReader.hasHeaders()) {
readSoapHeaders(xmlReader, context);
soapReader.endHeader();
}
soapReader.startBody();
if (soapReader.hasNonEmptyBody()) {
if (soapReader.isBodyFault()) {
// Handle SOAP Faults. Will need changes for SOAP 1.2
SoapFault fault = soapReader.startFault();
if (soapReader.startFaultDetail()) {
readSoapFaultDetail(xmlReader, context, fault);
soapReader.endFaultDetail();
}
soapReader.endFault();
context.setBody(fault);
} else {
// Handle SOAP body
context.invokeBodyReader(xmlReader);
if (context.getBody() == null) {
throw new WsException("No handlers could be found for unmarshalling the SOAP body payload");
}
}
}
soapReader.endBody();