none
MTOM-enabled WCF service sends document inline in SOAP response

    Question

  • Hi,

    I'm running a WCF service that has messageEncoding="Mtom" in the config file. The WCF service however, in its SOAP response sends the document as a Base 64 encoded document inline and not as a <xop:include.....> reference outside the SOAP. I'm not sure what I'm doing wrong. Please guide me.

    Thanks
    Bala

    Desired Format:

    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_F862C3E04D9E35266C1256303956115; type="application/xop+xml"; start="0.urn:uuid:F862C3E04D9E35266C1256303956116@apache.org"; start-info="application/soap+xml"; action="urn:ihe:iti:2007:RetrieveDocumentSetResponse"
    Date: Fri, 23 Oct 2009 13:19:11 GMT
    
    --MIMEBoundaryurn_uuid_F862C3E04D9E35266C1256303956115
    Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"
    Content-Transfer-Encoding: binary
    Content-ID: <0.urn:uuid:F862C3E04D9E35266C1256303956116@apache.org>
    
    <?xml version='1.0' encoding='UTF-8'?>
    <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
        xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <soapenv:Header>
            <wsa:Action>urn:ihe:iti:2007:RetrieveDocumentSetResponse</wsa:Action>
            <wsa:RelatesTo>urn:uuid:DCD262C64C22DB97351256303951276</wsa:RelatesTo>
        </soapenv:Header>
        <soapenv:Body>
            <xdsb:RetrieveDocumentSetResponse xmlns:xdsb="urn:ihe:iti:xds-b:2007">
                <rs:RegistryResponse xmlns:rs="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0"
                    status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success"/>
                <xdsb:DocumentResponse>
                    <xdsb:RepositoryUniqueId>1.19.6.24.109.42.1.5</xdsb:RepositoryUniqueId>
                    <xdsb:DocumentUniqueId>2009.9.1.1573</xdsb:DocumentUniqueId>
                    <xdsb:mimeType>application/pdf</xdsb:mimeType>
                    <xdsb:Document>
                        <xop:Include href="cid:1.urn:uuid:F862C3E04D9E35266C1256303956117@apache.org"
                            xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
                    </xdsb:Document>
                </xdsb:DocumentResponse>
            </xdsb:RetrieveDocumentSetResponse>
        </soapenv:Body>
    </soapenv:Envelope>
    
    --MIMEBoundaryurn_uuid_F862C3E04D9E35266C1256303956115
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: binary
    Content-ID: <1.urn:uuid:F862C3E04D9E35266C1256303956117@apache.org>
    
    This is the content of the document.
    
    --MIMEBoundaryurn_uuid_F862C3E04D9E35266C1256303956115
    Current Format:
    MIME-Version: 1.0
    Content-Type: type=text/xml
    Content-Description: XDS.b example using MTOM
    
    <?xml version='1.0' ?>
    <SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
    
    <!-- Metadata Goes Here -->
    ...
    <ExtrinsicObject id="mydocument" />
    ...
    <Document id="mydocument">base64 encoded document contents</Document>
    ...
    
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Wednesday, March 10, 2010 9:59 AM

Answers

  • Hi Bala,

    I wrote a MTOM sample, works well, here is my service side configuration file. 

      <system.serviceModel>
        <services>
          <service name="MTOM_WCF_1.Service1" behaviorConfiguration="MTOM_WCF_1.Service1Behavior">
            <!-- Service Endpoints -->
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="b1" contract="MTOM_WCF_1.IService1">
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="MTOM_WCF_1.Service1Behavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <wsHttpBinding>
            <binding name="b1" messageEncoding="Mtom">
              <security mode="None" />
              <reliableSession enabled="false" />
            </binding>
          </wsHttpBinding>
        </bindings>
      </system.serviceModel>

    And make sure that access the corresponding service endpoint on client side.

    Thanks,
    Mog Liang
    • Marked as answer by Mog Liang Wednesday, March 17, 2010 4:02 AM
    Monday, March 15, 2010 2:00 AM

All replies

  • Generally, Wcf applies MTOM only when the message is over some size.
    However the case here seems to be a wrong binding configuration, since the response content-Type is not of mtom.
    Please publish your configuration file.

    http://webservices20.blogspot.com/
    WCF Security, Performance And Testing Blog
    Wednesday, March 10, 2010 11:35 PM
  • Thanks for taking the time to help with my request.

    I did read about this limit sometime back. So, i tested with large pdfs and still got the same type of response. So we can safely disregard that for the moment. 

    The following is the section of the config where I have mtom defined:

    <binding name="XDSRepository_HTTP" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None" />
                <message clientCredentialType="None" establishSecurityContext="false" negotiateServiceCredential="false" />
              </security>
            </binding>

    Thanks
    Bala
    Thursday, March 11, 2010 8:12 AM
  • please publish the full app.config
    http://webservices20.blogspot.com/
    WCF Security, Performance And Testing Blog
    Thursday, March 11, 2010 10:53 PM
  • Hi Bala,

    I wrote a MTOM sample, works well, here is my service side configuration file. 

      <system.serviceModel>
        <services>
          <service name="MTOM_WCF_1.Service1" behaviorConfiguration="MTOM_WCF_1.Service1Behavior">
            <!-- Service Endpoints -->
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="b1" contract="MTOM_WCF_1.IService1">
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="MTOM_WCF_1.Service1Behavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <wsHttpBinding>
            <binding name="b1" messageEncoding="Mtom">
              <security mode="None" />
              <reliableSession enabled="false" />
            </binding>
          </wsHttpBinding>
        </bindings>
      </system.serviceModel>

    And make sure that access the corresponding service endpoint on client side.

    Thanks,
    Mog Liang
    • Marked as answer by Mog Liang Wednesday, March 17, 2010 4:02 AM
    Monday, March 15, 2010 2:00 AM