if (relayParam == null) {
handleException("Relay not initialized");
}
RelayConfiguration relConf = (RelayConfiguration) relayParam.getValue();
if (relConf == null) {
handleException("Relay not initialized");
}
if (isFilteredOutService(msgContext.getAxisService(), relConf)) {
SOAPEnvelope envelope = msgContext.getEnvelope();
OMElement contentEle = envelope.getBody().getFirstChildWithName(
RelayConstants.BINARY_CONTENT_QNAME);
if (contentEle != null) {
OMNode node = contentEle.getFirstOMChild();
if (node != null && (node instanceof OMText)) {
OMText binaryDataNode = (OMText) node;
DataHandler dh = (DataHandler) binaryDataNode.getDataHandler();
if (dh == null) {
if (log.isDebugEnabled()) {
log.warn("Message has the Binary content element. " +
"But doesn't have binary content embedded within it");
}
return InvocationResponse.CONTINUE;
}
DataSource dataSource = dh.getDataSource();
//Ask the data source to stream, if it has not alredy cached the request
if (dataSource instanceof StreamingOnRequestDataSource) {
((StreamingOnRequestDataSource) dataSource).setLastUse(true);
}
InputStream in = dh.getInputStream();
//extract the wrapped binary content
//Select the right builder, create the envelope and stick it in.
String contentType = (String) msgContext.getProperty(
Constants.Configuration.CONTENT_TYPE);
OMElement element = relConf.getMessageBuilder()
.getDocument(contentType, msgContext, in);
if (element != null) {
msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(element));
msgContext.setProperty(MessageBuilder.RELAY_FORMATTERS_MAP,
relConf.getMessageBuilder().getFormatters());
} else {
log.warn("Error building the message, skipping message building");
}
//now we have undone thing done by Relay
if (log.isDebugEnabled()) {