@Override public Source respond(SoapOperation invokedOperation, SoapMessage message) { Exchange exchange = new DefaultExchange(getCamelContext(), ExchangePattern.InOut); Document messageDocument = message.getDocument(); String requestBody = envelopeWrapper.unwrap(messageDocument, getCamelContext()); exchange.getIn().setBody(requestBody); exchange.getIn().setHeader(OPERATION, invokedOperation.getOperationName()); try { getProcessor().process(exchange); if (exchange.getException() != null) { throw exchange.getException(); } Message responseMessage = exchange.getOut(Message.class); if (responseMessage != null) { String responseBody = responseMessage.getBody(String.class); return envelopeWrapper.wrapToSource(responseBody, getCamelContext()); } else { throw new IllegalArgumentException( "Could not find output message, exchange: " + exchange); } } catch (Exception ex) { throw new SoapServerException(ex); } }
@Override public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException { SoapMessage soapMsg = (SoapMessage) message; SoapHeader header = soapMsg.getSoapHeader(); SoapHeaderElement edCodeHeader = header.addHeaderElement(getEdCode()); edCodeHeader.setText(getEdCodeText()); SoapHeaderElement cutOffDate = header.addHeaderElement(getCutOffDate()); cutOffDate.setText(getCutOffDateText()); SoapHeaderElement signatureData = header.addHeaderElement(getSignatureData()); signatureData.setText(getSignatureDataText()); SoapHeaderElement uploadDate = header.addHeaderElement(getUploadDate()); uploadDate.setText(getUploadDateText()); // Call the superclass method to add WS-Addressing headers super.doWithMessage(message); }