Announcement Announcement Module
Collapse
No announcement yet.
MTOM without JAXB2-Databinding Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MTOM without JAXB2-Databinding

    Hi all!

    I want to write a simple WS which lets mit download a binary file using MTOM-Encoding (client is using Axis2).

    I dont want to use JAXB2 for databinding because its a simple example and I dont want to learn another binding framework.
    For the example I want to use no databinding framework at all and instead use plain MimeMessage-Class.

    Can anyone tell me the steps for creating an MTOM-Message by hand?
    I think it must be something like this:

    1.) create empty MimeMessage from WebServiceMessageFactory
    MimeMessage message = factory.createWebServiceMessage();

    2.) create Response-XML using DOM, StAX or something else

    3.) create an <xop:Include/> node referencing the attachment part

    4.) add the attachment to the MimeMessage using
    MimeMessage.addAttachment(String contentId, DataHandler dataHandler)

    6.) convert the MimeMessage to an XopPackage using
    MimeMessage.convertToXopPackage()


    I'm currently using AxiomSoapMessageFactory.
    I looked at the sourcecode of the AxiomSoapMessage (implements MimeMessage) and found that the convertToXopPackage()-Method in this class does nothing.

    Is it true that I have to use SAAJ for MTOM and has anyone of created MTOM-Messages without JAXB2-Databinding?

    thx
    Herbert

  • #2
    Currently, MTOM only works for SAAJ, because the Axiom model to deal with MTOM is fundamentally different than the SAAJ model. I have not really had the time to find a way to make the current model work for Axiom as well.

    For using SAAJ, the steps given are correct. If you do want to use Axiom, you can use the native API of Axiom. See http://ws.apache.org/axis2/1_1/mtom-guide.html#21. You can get the axiom SOAPMessage by calling getAxiomMessage() on the AxiomSoapMessage class.

    Comment


    • #3
      Hi!

      I've now a working Spring-WS-MTOM Webservice without JAXB2-Databinding (it's based on MessageEndpoint-Implementation).

      On client-side (Axis2) I had to write a patch for org.apache.axis2.builder.BuilderUtil because Axis2 chooses a Builder-Implementation (for parsing the request) based on the Content-Type of the MIME-Part.
      While Axis2 looks for "multipart/related" in the request, Spring-WS (SAAJ) sends "Multipart/Related" which gave me the following error message:

      WstxUnexpectedCharException: Unexpected ch aracter '-' (code 45) in prolog; expected '<'

      After changing the method org.apache.axis2.builder.BuilderUtil.getBuilderFro mSelector()

      from:

      public static Builder getBuilderFromSelector(String type, MessageContext msgContext)
      throws AxisFault {

      Builder builder = msgContext.getConfigurationContext().getAxisConfig uration()
      .getMessageBuilder(type);
      if (builder != null) {
      // Setting the received content-type as the messageType to make
      // sure that we respond using the received message serialisation
      // format.
      msgContext.setProperty(Constants.Configuration.MES SAGE_TYPE, type);
      }
      return builder;
      }

      to:

      public static Builder getBuilderFromSelector(String type, MessageContext msgContext)
      throws AxisFault {

      Builder builder = msgContext.getConfigurationContext().getAxisConfig uration()
      .getMessageBuilder(type.toLowerCase());
      if (builder != null) {
      // Setting the received content-type as the messageType to make
      // sure that we respond using the received message serialisation
      // format.
      msgContext.setProperty(Constants.Configuration.MES SAGE_TYPE, type.toLowerCase());
      }
      return builder;
      }

      it works.

      Thx

      Comment


      • #4
        Hi

        What if I have not chance to write patch.
        Mine client can not process any response becasuse we send them Multipart/Related instead of multipart/related.
        Is there any solution on server (spring ws, saaj) side ?
        Can I do lowercase operation somehow for content type ?

        Comment


        • #5
          In spring webservice MTOM should work only JAXB2 databinding. I have developed MTOM spring webservice download the files use jaxb2 databinding it should working fine all the clients.

          Comment

          Working...
          X