return;
}
message.put(BODY_FILLED_IN, Boolean.TRUE);
try {
SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
if (soapMessage == null) {
MessageFactory factory = preInterceptor.getFactory(message);
soapMessage = factory.createMessage();
message.setContent(SOAPMessage.class, soapMessage);
}
XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
if (xmlReader == null) {
return;
}
final SOAPPart part = soapMessage.getSOAPPart();
Document node = (Document) message.getContent(Node.class);
if (node != part && node != null) {
StaxUtils.copy(node, new SAAJStreamWriter(part));
}
message.setContent(Node.class, soapMessage.getSOAPPart());
Collection<Attachment> atts = message.getAttachments();
if (atts != null) {
for (Attachment a : atts) {
if (a.getDataHandler().getDataSource() instanceof AttachmentDataSource) {
try {
((AttachmentDataSource)a.getDataHandler().getDataSource()).cache(message);
} catch (IOException e) {
throw new Fault(e);
}
}
AttachmentPart ap = soapMessage.createAttachmentPart(a.getDataHandler());
Iterator<String> i = a.getHeaderNames();
while (i != null && i.hasNext()) {
String h = i.next();
String val = a.getHeader(h);
ap.addMimeHeader(h, val);
}
if (StringUtils.isEmpty(ap.getContentId())) {
ap.setContentId(a.getId());
}
soapMessage.addAttachmentPart(ap);
}
}
//replace header element if necessary
if (message.hasHeaders()) {
replaceHeaders(soapMessage, message);
}
if (soapMessage.getSOAPPart().getEnvelope().getHeader() == null) {
soapMessage.getSOAPPart().getEnvelope().addHeader();
}
StaxUtils.copy(xmlReader,
new SAAJStreamWriter(soapMessage.getSOAPPart(),
soapMessage.getSOAPPart().getEnvelope().getBody()),
true, true);
DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
xmlReader = StaxUtils.createXMLStreamReader(bodySource);
xmlReader.nextTag();
xmlReader.nextTag(); // move past body tag
message.setContent(XMLStreamReader.class, xmlReader);
} catch (SOAPException soape) {