SOAP MTOM(Message Transmission Optimization Mechanism)은 W3C(World Wide Web Consortium)에서 개발된 표준입니다. MTOM은 선택적으로 메시지의 일부를 다시 인코딩하여 SOAP 메시지의 전송이나 회선 형식을 최적화하고 SOAP 애플리케이션에 대해서는 XML 정보 세트(Infoset)를 계속 표시하는 메커니즘에 대해 설명합니다.
MTOM에서는 SOAP/HTTP 및 MIME/HTTP 컨텍스트에서 XOP(XML-binary Optimized Packaging)를 사용합니다. XOP는 SOAP 및 MIME 패키지 뿐만 아니라 XML Infoset 및 패키징 메커니즘에도 적용되는 2진 컨텐츠가 포함된 XML Infoset에 대한 직렬화 메커니즘을 정의합니다. 이는 결국 MIME 멀티파트 또는 연관된 패키지와 유사하게 보여주는 루트 파트의 XML 문서가 포함된 XML의 대체 직렬화입니다. 해당 루트 파트는 문서의 XML 직렬화와 매우 유사하며 단지 base64 인코딩이 아닌 MIME 파트 중 하나로 참조되어 base64 인코딩 데이터가 교체되는 점이 다릅니다. 이 참조를 사용하여 인코딩과 연관된 처리에서 벌크 및 오버헤드를 방지할 수 있습니다. 인코딩은 2진 데이터를 XML로 작업할 수 있는 유일한 방법입니다.
MTOM 맵핑 생성이 사용 불가능한 경우 XOP가 사용 불가능합니다. XOP가 사용 불가능한 경우 2진 데이터는 MIME 첨부 방식으로 송신되지 않습니다. 대신 2진 데이터는 일반적인 Base-64로 인코딩 됩니다.
MTOM이 없는 경우 데이터는 스키마(base64 또는 16진)에서 설명된 형식으로 인코딩되어 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이 사용 가능한 경우 첨부를 나타내는 2진 데이터는 SOAP 메시지의 MIME 첨부로 포함됩니다. 다음 예제는 첨부 데이터가 포함된 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 Message Transmission Optimization Mechanism을 참조하십시오.