MTOM Support on the WSDL Level

To enable MTOM, the slight modification of WSDL file is needed.

<schema targetNamespace="http://pictures.com"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <element name="Picture">
    <complexType>
      <sequence>
        <element name="Title" type="xsd:string"/>
        <element name="ImageData" type="xsd:base64Binary"/>
      </sequence>
    </complexType>
  </element>
</schema>

...is going to change to:

<schema targetNamespace="http://pictures.com"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
  <element name="Picture">
    <complexType>
      <sequence>
        <element name="Title" type="xsd:string"/>
        <element name="ImageData" type="xsd:base64Binary"
           xmime:expectedContentTypes="application/octet-stream"/>
      </sequence>
    </complexType>
  </element>
</schema>

(Source: http://cxf.apache.org/docs/mtom-attachments-with-jaxb.html)

In other words, only new xml attribute expectedContentTypes from namespace with URI http://www.w3.org/2005/05/xmlmime is set to the value application/octet-stream.

Affected API-M Methods

There is little discrepancy between API-M WSDL definition of method modifyDatastreamByValue and it's web definition on (https://wiki.duraspace.org/display/FCR30/API-M#API-M-modifyDatastreamByValue). WSDL says attribute dsContent is of type byte[], but web says String. I suppose, the byte[] as the correct type.  (You're correct, Jiri. I've fixed the documentation. - Chris)

Affected API-A Methods

Methods marked as red has an input parameter of type byte[] and blue methods has output value of type byte[].

Changes to WSDL

Since API-A and API-M wsdl files both use the include directive inside their <types> element, the changes will be made only to fedora-types.xsd.

Two sides of MTOM

MTOM can be enabled on both the client and the server side. If it is done on the client side, then the SOAP requests with binary data are "MTOMized" and if it is done on the server side, then the responses are. So far, it seems that either client or server (generated by CXF) can handle both MTOM (multipart/related) and non-MTOM (text/xml) SOAP messages in runtime without knowing in advance what type should be received. I am affraid that some old WS client won't be able to provide such a functionality, therefore new set of methods with MTOM support has to be created in order not to break backward compatibility wtih MTOM clients not understanding the MTOM/XOP coding. Another backward compatible solution could be for instance to return MTOMed message if and only if there is some special attribute in HTTP header of SOAP request, however, I haven't found how to change this behaviour of WS programmatically in runtime.

Also there might be some complication with this issue http://stackoverflow.com/questions/2808967/mtom-request-non-mtom-response.

Possible Solutions

All the solutions are backward compatible.

  1. One WSDL rule them all
    1. MTOMize only "blue" operations
    2. MTOMize all MTOMizable operations
  2. New WSDLs and endpoints for MTOMized version of API
  3. Routing (Mediator Pattern)

Visualization in pseudo UML

1.a & 1.b

   


2. (the lower rectangles are MTOM enabled)
 


3.
 

Pros:

Cons:

The Winner

To be honest, I don't know. I would suggest the solution number 3. i.e. the router and new WSDLs, because it seems to me the best choice for possible future changes to Fedora's API. I had also some discussion with my friends which support this proposal.

Namespaces

suggestion:

prefix

old

new

fedora-types

http://www.fedora.info/definitions/1/0/types/ http://fedora-commons.org/2011/07/definitions/types/

fedora-api

http://www.fedora.info/definitions/1/0/api/ http://fedora-commons.org/]2011/07/definitions/api/

References