[英]How to detect in Java if SOAP message is MTOM
Java(1.6)中有什么方法可以檢測SOAP消息是否為MTOM,還是需要為此創建方法來檢查消息是否包含多個部分?
基於SOAP 1.2規范
通過檢查application / xop + xml媒體類型的存在來確定是否使用HTTP SOAP傳輸優化功能
但我在測試(最小化)情況下的MTOM消息中看不到它
------=_Part_0_591998098.1543337064443
Content-Type: application/soap+xml; charset=utf-8
<soapenv:Envelope>some SOAP message</soapenv:Envelope>
------=_Part_0_591998098.1543337064443
Content-Type: null
Content-ID: <1.4a159e8e@apache.org>
Content-Transfer-Encoding: binary
Content-Type: text/html
<?xml version="1.0" encoding="us-ascii"?><html><head><title>testlf</title></head><body><b>Message Type: </b>Direct<br /><b>Subject: </b>testlf<br /><hr /></body></html>
------=_Part_0_591998098.1543337064443
Content-Type: application/octet-stream
Content-ID: <http://tempuri.org/1/635742060149828871>
Content-Transfer-Encoding: binary
<?xml version='1.0'?><?xml-stylesheet type='text/xsl'?>Here is PDF
------=_Part_0_591998098.1543337064443--
我結束了
private boolean isMTOM(SOAPMessage msg) throws SOAPException, IOException
{
boolean isMTOM = false;
MimeHeaders headers = msg.getMimeHeaders();
String[] contentType = headers.getHeader("Content-Type");
if(contentType[0].toLowerCase().contains("multipart/related") && (contentType[0].toLowerCase().contains("application/soap+xml") || contentType[0].toLowerCase().contains("application/xop+xml"))) {
isMTOM = true;
}
return isMTOM;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.