如何在 Java 中检测 SOAP 消息是否为 MTOM

How to detect in Java if SOAP message is MTOM

Java (1.6) 中是否有任何方法可以检测 SOAP 消息是否为 MTOM,或者我是否需要为此创建方法来检查消息是否具有多部分?

基于 SOAP 1.2 规范

determine whether the HTTP SOAP Transmission Optimization Feature is used by checking the presence of the application/xop+xml media type

但我没有在我的 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;
}