Is MTOM attachment handling supported through the Dispatch SPI?
I have modified the jaxws_dispatch_provider CXF sample, to accept/send
payloads that contain Base64Binary data.
#######################################################################
Schema:
#######
<complexType name="DocumentDetailType">
<sequence>
<element name="identifier" type="xsd:string"/>
<element name="content" type="xsd:base64Binary"/>
</sequence>
</complexType>
<complexType name="DocumentType">
<sequence>
<element name="name" type="xsd:string"/>
<element name="id" type="xsd:string"/>
<element name="detail" type="types:DocumentDetailType"/>
</sequence>
</complexType>
<element name="testDocumentRequest" type="types:DocumentType" />
<element name="testDocumentResponse" type="types:DocumentType" />
#######################################################################
#######################################################################
Request Message sample:
#######
------=_Part_4_8271067.1271948982000
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <[email protected]>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://cxf.apache.org/mime/types">
<soapenv:Header/>
<soapenv:Body>
<typ:testDocument>
<typ:name>RequestSOAPUI_01</typ:name>
<typ:id>RequestSOAPUI_01_id</typ:id>
<typ:detail>
<typ:identifier>RequestSOAPUI_01_identifier</typ:identifier>
<typ:content><inc:Include href="cid:217539756627" xmlns:inc="
http://www.w3.org/2004/08/xop/include"/></typ:content>
</typ:detail>
</typ:testDocument>
</soapenv:Body>
</soapenv:Envelope>
------=_Part_4_8271067.1271948982000
Content-Type: text/xml; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-ID: <217539756627>
PGE+DQogIDxiIG5hbWU9IlRob21hcyIvPg0KPGE+
------=_Part_4_8271067.1271948982000--
#######################################################################
#######################################################################
Apache CXF dispatch provider:
#######
@MTOM(threshold = 0, enabled = true)
@WebServiceProvider(
portName = "TestDocumentPort",
serviceName = "TestDocumentService",
targetNamespace = "http://cxf.apache.org/mime",
wsdlLocation = "wsdl/mtom_xop.wsdl")
@ServiceMode(value = Service.Mode.MESSAGE)
public class TestDocumentDomSourceMessageProvider implements
Provider<DOMSource> {
public TestDocumentDomSourceMessageProvider() {
}
public DOMSource invoke(DOMSource request) {
DOMSource response = new DOMSource();
try {
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage();
soapReq.getSOAPPart().setContent(request);
System.out.println("Incoming Client Request as a DOMSource data
in MESSAGE Mode");
soapReq.writeTo(System.out);
System.out.println("\n");
InputStream is =
getClass().getResourceAsStream("TestDocumentResponse.xml");
SOAPMessage testDocumentResponse = factory.createMessage(null,
is);
is.close();
response.setNode(testDocumentResponse.getSOAPPart());
} catch (Exception ex) {
ex.printStackTrace();
}
return response;
}
}
Object implementor = new TestDocumentDomSourceMessageProvider();
String address = "http://localhost:9000/document-test";
Endpoint ep = Endpoint.publish(address, implementor);
((SOAPBinding)ep.getBinding()).setMTOMEnabled(true);
#######################################################################xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="
http://cxf.apache.org/mime/types">
I had hoped that the Apache runtime would process the attachment and inline
it into the
'DOMSource request' before the 'invoke' method is called, but it appears
that no mtom
processing takes place.