Search code examples
javasoapwebspherewebsphere-libertymtom

MTOM - Root content type was always text/xml


I am using MTOM to stream the attached file from client to the server.

The MTOM gets applied and the file is streamed as binary. But the root Content-Type was always "text/xml" which should be "application/xml+xop".

The problems occurs only in websphere. The content type was set as "text/xml" in websphere.

In websphere liberity profile, the content type was set as "application/xml+xop"

------=_Part_7283_-2062365125.1458743649653
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <511212039242.1458743649653.IBM.WEBSERVICES@lsrv4665.linux.rabobank.nl>

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Header>
        </soapenv:Header>
        <soapenv:Body>
          <Content><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:58cf03d2-322f-4819-80fb-3b001f497d12%40www.test.com"/>
          </Content>
        </soapenv:Body>
    </soapenv:Envelope>

    Content-Type: application/pdf; name=attachment.pdf

Content-Transfer-Encoding: binary

Solution

  • Able to resolve this issue by using saaj-impl jar.

    pom.xml

     <dependency>
        <groupId>com.sun.xml.messaging.saaj</groupId>
        <artifactId>saaj-impl</artifactId>
        <version>1.3.16</version>
        <scope>provided</scope>
     </dependency>
    

    dispatcher-servlet.xml

    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
      <property name="messageFactory">
        <bean class="com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl" />
      </property>
    </bean>