SOAP MTOM

「SOAP 訊息傳輸最佳化機制 (MTOM)」是「全球資訊網協會 (W3C)」所開發的標準。 MTOM 說明 SOAP 訊息傳輸或發訊格式的最佳化機制,此機制會選擇性地將訊息的某些部分重新編碼,但還是會向 SOAP 應用程式呈現「XML 資訊集」。

MTOM 在 SOAP 和 MIME over HTTP 的環境定義中使用「XML 二進位最佳化包裝 (XOP)」。XOP 針對含有二進位內容的「XML 資訊集」,定義一套序列化機制,此機制不僅適用於 SOAP 和 MIME 包裝,也適用於任何「XML 資訊集」和任何包裝機制。它是 XML 序列化的替代方式,只是剛好看起來像 MIME 多組件或相關的套件,而 XML 文件為根的部分。那個根部分與文件的 XML 序列化非常類似,只是 Base64 編碼資料換成了對 MIME 某部分的參照,而該部分不是 Base64 編碼。此參照可讓您在處理過程中,避免與編碼相關聯的大量額外負荷。編碼是二進位資料可以直接使用 XML 的唯一方式。

如果停用 MTOM 對映產生,XOP 也會停用。如果 XOP 停用,就不會使用 MIME 附件來傳送二進位資料,而是會像平常一樣,以 base64 將二進位資料編碼。

如果沒有 MTOM,就會以綱目中說明的任何格式來將資料編碼(base64 或十六進位),然後將資料顯示在 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 訊息傳輸最佳化機制

Icon that indicates the type of topic Concept topic
Timestamp icon Last updated: last_date

File name: cmtom.html