如何解析包含格式良好的 XML 和二进制数据的 http post 内容?
我正在以 http 帖子的形式接收来自移动设备的彩信到某些网络应用程序。当我收到内容时,它包含一些原始信息、格式良好的 XML 和二进制格式的数据(即图像)。
我想获取 XML,以便可以解析它并从内容中获取二进制数据,将其转换为图像。
以下是内容样本:
------=_Part_121809_1523072928.1286496211187
Content-Type: text/xml
Content-ID: <soap-start>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4"><ns1:Header><ns3:TransactionID ns1:mustUnderstand="1">GW0110L-M1007N6-M200331G0-SNSRPN</ns3:TransactionID></ns1:Header><ns1:Body><ns3:DeliverReq><ns3:MM7Version>6.8.0</ns3:MM7Version><ns3:LinkedID>GW0110L-M1007N6-M200331G0-SNSRPN</ns3:LinkedID><ns3:Sender><ns3:Number>+16123060744/TYPE=PLMN</ns3:Number></ns3:Sender><ns3:Recipients><ns3:To><ns3:Number displayOnly="false">466466</ns3:Number></ns3:To></ns3:Recipients><ns3:TimeStamp>2010-10-08T00:03:29.897Z</ns3:TimeStamp><ns3:Priority>Normal</ns3:Priority><ns3:Subject>New Message</ns3:Subject><ns3:UACapabilities UAProf="MF:304~Model:SPHM320ZSS"/><ns3:Content allowAdaptations="true" href="cid:default.cid"/></ns3:DeliverReq></ns1:Body></ns1:Envelope>
------=_Part_121809_1523072928.1286496211187
Content-Type: multipart/mixed;
boundary="----=_Part_121810_281628656.1286496211187"
Content-ID: <default.cid>
------=_Part_121810_281628656.1286496211187
Content-Type: application/smil
Content-Transfer-Encoding: 7bit
Content-ID: <<applicationsmil_1.smil>>
<smil>
<head>
<layout>
<root-layout height="160" width="160"/>
<region height="120" id="Image" left="0" top="0" width="160"/>
<region height="40" id="Text" left="0" top="120" width="160"/>
</layout>
</head>
<body>
<par dur="5s">
<img region="Image" src="imagejpeg_2.jpg"/>
</par>
</body>
</smil>
------=_Part_121810_281628656.1286496211187
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-ID: <<imagejpeg_2.jpg>>
ÿØÿà�JFIF������ÿÛ�C�
$4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ���?�ýø¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(YÕmt?êšÞ H³Óí$ºœ¢å¶D¥›‚×à/Æß|Ô¾6èZ^kÚ<º¬ú„ÏwföþG÷Q7§È¿süîl¯è
ä¢Ù²Kl÷qÈ|·T?
÷·nþþ>5k:ý¶<M¦7†µ_ÚørÊ{k;û
òÁ½÷¶ç‹z?ÈŸ'Ï÷6r¾gˆ ±‘£7›],—^ŸvæÊo~ÿ�Ò<¾Ú?�ëšÏµ»)tÛ
="‚Ù,¦Kt“æÛ±þ÷ëÄ.´[ï‚·3ÛßÜ[Yß\¬%¹ß.ç•+Ôl5ÏÚþÌþ0ׯ-m~Ó¨^3[E,?Åüü_ü¹[ßø"ßAðm„Ž›s~×>dßdº»~_üzº£R¤å÷SÙëoŘTåå哳í`Ô¬e‡ÅÞÒî5›¯ô]ÛÝ?t»v|¿í|ÔË?R_ø“V‹Ä>
I am receiving mobile originated MMS to some web app as http post. When I receive the content it includes some raw information, a well formed XML and Binary formatted data (i.e. Image).
I want to fetch the XML so I can parse it and binary data from the content to convert it into an image.
Following is the content sample:
------=_Part_121809_1523072928.1286496211187
Content-Type: text/xml
Content-ID: <soap-start>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4"><ns1:Header><ns3:TransactionID ns1:mustUnderstand="1">GW0110L-M1007N6-M200331G0-SNSRPN</ns3:TransactionID></ns1:Header><ns1:Body><ns3:DeliverReq><ns3:MM7Version>6.8.0</ns3:MM7Version><ns3:LinkedID>GW0110L-M1007N6-M200331G0-SNSRPN</ns3:LinkedID><ns3:Sender><ns3:Number>+16123060744/TYPE=PLMN</ns3:Number></ns3:Sender><ns3:Recipients><ns3:To><ns3:Number displayOnly="false">466466</ns3:Number></ns3:To></ns3:Recipients><ns3:TimeStamp>2010-10-08T00:03:29.897Z</ns3:TimeStamp><ns3:Priority>Normal</ns3:Priority><ns3:Subject>New Message</ns3:Subject><ns3:UACapabilities UAProf="MF:304~Model:SPHM320ZSS"/><ns3:Content allowAdaptations="true" href="cid:default.cid"/></ns3:DeliverReq></ns1:Body></ns1:Envelope>
------=_Part_121809_1523072928.1286496211187
Content-Type: multipart/mixed;
boundary="----=_Part_121810_281628656.1286496211187"
Content-ID: <default.cid>
------=_Part_121810_281628656.1286496211187
Content-Type: application/smil
Content-Transfer-Encoding: 7bit
Content-ID: <<applicationsmil_1.smil>>
<smil>
<head>
<layout>
<root-layout height="160" width="160"/>
<region height="120" id="Image" left="0" top="0" width="160"/>
<region height="40" id="Text" left="0" top="120" width="160"/>
</layout>
</head>
<body>
<par dur="5s">
<img region="Image" src="imagejpeg_2.jpg"/>
</par>
</body>
</smil>
------=_Part_121810_281628656.1286496211187
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-ID: <<imagejpeg_2.jpg>>
ÿØÿà�JFIF������ÿÛ�C�
$4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ���?�ýø¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(YÕmt?êšÞ H³Óí$ºœ¢å¶D¥›‚×à/Æß|Ô¾6èZ^kÚ<º¬ú„ÏwföþG÷Q7§È¿süîl¯è
ä¢Ù²Kl÷qÈ|·T?
÷·nþþ>5k:ý¶<M¦7†µ_ÚørÊ{k;û
òÁ½÷¶ç‹z?ÈŸ'Ï÷6r¾gˆ ±‘£7›],—^ŸvæÊo~ÿ�Ò<¾Ú?�ëšÏµ»)tÛ
="‚Ù,¦Kt“æÛ±þ÷ëÄ.´[ï‚·3ÛßÜ[Yß\¬%¹ß.ç•+Ôl5ÏÚþÌþ0ׯ-m~Ó¨^3[E,?Åüü_ü¹[ßø"ßAðm„Ž›s~×>dßdº»~_üzº£R¤å÷SÙëoŘTåå哳í`Ô¬e‡ÅÞÒî5›¯ô]ÛÝ?t»v|¿í|ÔË?R_ø“V‹Ä>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有关您将使用哪个平台/框架来实现您的目的的信息
你的问题中缺少。
如果您使用 Java,请尝试这个库:
http://jmmslib.sourceforge.net/
The information about which platform/framework you're going to use for your purpose
is missing in your question.
If you're using Java, try this lib:
http://jmmslib.sourceforge.net/