[英]How to detect in Java if SOAP message is MTOM
Is there any way in Java (1.6) to detect if SOAP message is MTOM or do I need to create method for that to check if message has multiparts? Java(1.6)中有什么方法可以检测SOAP消息是否为MTOM,还是需要为此创建方法来检查消息是否包含多个部分?
Based on the SOAP 1.2 specs to 基于SOAP 1.2规范
determine whether the HTTP SOAP Transmission Optimization Feature is used by checking the presence of the application/xop+xml media type
通过检查application / xop + xml媒体类型的存在来确定是否使用HTTP SOAP传输优化功能
but I don't see it in my MTOM message which in a test (minimalistic) case looks like 但我在测试(最小化)情况下的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--
I have ended up with 我结束了
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.