Attachments attachments =
new Attachments(inputStream, contentType, attachmentCaching, attachmentCacheDir.getAbsolutePath(),
Integer.toString(attachmentCacheThreshold));
XMLStreamReader reader = inputFactory.createXMLStreamReader(attachments.getRootPartInputStream(),
getCharSetEncoding(attachments.getRootPartContentType()));
StAXSOAPModelBuilder builder;
String envelopeNamespace = getSoapEnvelopeNamespace(contentType);
if (MTOMConstants.SWA_TYPE.equals(attachments.getAttachmentSpecType()) ||
MTOMConstants.SWA_TYPE_12.equals(attachments.getAttachmentSpecType())) {
builder = new StAXSOAPModelBuilder(reader, soapFactory, envelopeNamespace);
}
else if (MTOMConstants.MTOM_TYPE.equals(attachments.getAttachmentSpecType())) {
builder = new MTOMStAXSOAPModelBuilder(reader, attachments, envelopeNamespace);
}
else {
throw new AxiomSoapMessageCreationException(
"Unknown attachment type: [" + attachments.getAttachmentSpecType() + "]");
}
return new AxiomSoapMessage(builder.getSoapMessage(), attachments, soapAction, payloadCaching,
langAttributeOnSoap11FaultString);
}