SOAP MTOM

SOAP 消息传输优化机制 (MTOM) 是万维网联盟 (W3C) 开发的标准。MTOM 描述一个机制,该机制用于通过有选择地重新编码部分消息但仍向 SOAP 应用程序显示 XML 信息集来优化 SOAP 消息的传输或有线格式。

MTOM 在 SOAP 和 MIME over HTTP 的上下文中使用 XML 二进制优化打包 (XOP)。XOP 定义了一种序列化机制,该机制用于具有不适合 SOAP 和 MIME 打包、但适合任何 XML 信息集和任何打包机制的二进制内容的 XML 信息集。这是 XML 的替代序列化,只是看上去像 MIME 多个部件或相关包,将 XML 文档用作根部件。除了基本 64 位编码的数据替换为对非基本 64 位编码的其中一个 MIME 部件的引用之外,该根部件与文档的 XML 序列化非常相似。此引用使您能够在与编码相关联的处理方面节省大量开销。编码是可将二进制数据直接处理 XML 的唯一方法。

如果禁用 MTOM 映射生成,就会禁用 XOP。如果禁用 XOP,就不能通过使用 MIME 附件发送二进制数据。而是像平时一样使用基本 64 位对二进制数据进行编码。

没有 MTOM,无论用什么格式编码的数据都会用模式(基本 64 位或十六进制)描述,然后显示在 XML 文档中。以下示例显示了具有 <xsd:base64Binary> 元素的 SOAP 消息:

... other transport headers ... 
Content-Type: text/xml; charset=UTF-8

<?xml version="1.0" encoding="UTF-8"?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Header/>
      <soapenv:Body>
         <sendImage xmlns="http://org/apache/axis2/jaxws/sample/mtom">
            		<input>
               <imageData>R0lGODl  ... more base64 encoded data ...  KTJk8giAAA7</imageData>
            </input>
         </sendImage>
      </soapenv:Body>
   </soapenv:Envelope>

如果启用了 MTOM,表示附件的二进制数据就会作为 MIME 附件包括到 SOAP 消息中。以下示例显示具有附件数据的支持 MTOM 的 SOAP 消息:

... other transport headers ... 
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812; 
type="application/xop+xml"; start="<0.urn:uuid:0FE43E4D025F0BF3DC11582467646813@apache.org>"; 
start-info="text/xml"; charset=UTF-8

--MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812
content-type: application/xop+xml; charset=UTF-8; type="text/xml";
content-transfer-encoding: binary
content-id: 
   <0.urn:uuid:0FE43E4D025F0BF3DC11582467646813@apache.org>


         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
            <soapenv:Header/>
            <soapenv:Body>
               <ati:sendImage xmlns="http://org/apache/axis2/jaxws/sample/mtom" xmlns:ati="http://org/apache/axis2/jaxws/sample/mtom">
                  <ati:input>
                     <ati:imageData>
                        <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1.urn:uuid:0FE43E4D025F0BF3DC11582467646811@apache.org"/>
                     </ati:imageData>
                  </ati:input>
               </ati:sendImage>
            </soapenv:Body>
         </soapenv:Envelope>
--MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812
content-type: text/plain
content-transfer-encoding: binary
content-id: 
         <1.urn:uuid:0FE43E4D025F0BF3DC11582467646811@apache.org>

... binary data goes here ...
--MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812--

有关更多信息,请参阅正式 MTOM 规范:SOAP 消息传输优化机制

指示主题类型的图标 概念主题
信息中心的条款和条件 | 反馈

时间戳记图标 最近一次更新时间: 2014 年 4 月 17 日

文件名:cmtom.html