从SOAP响应中检索MIME多部分数据

时间:2013-06-08 04:01:45

标签: python soap mime

我正在使用Python和Suds来使用SOAP Web服务,有时,当响应数据太大时,它会将响应格式切换为WS-Attachment。它应该是一个完整的MIME消息,但相反,我只得到“边界”部分,如下所示:

------=_Part_2_27050467.1235668849951
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <0F082AF1DAF83B3077B1867B4FC8AAA6>

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
    <ns1:runReportResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://axis2.ws.jasperserver.jaspersoft.com">
        <runReportReturn xsi:type="xsd:string">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;operationResult version=&quot;2.0.1&quot;&gt;\n\t&lt;returnCode&gt;&lt;![CDATA[0]]&gt;&lt;/returnCode&gt;\n&lt;/operationResult&gt;\n
        </runReportReturn>
    </ns1:runReportResponse>
</soapenv:Body>
</soapenv:Envelope>
------=_Part_2_27050467.1235668849951
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Id: <report>

%PDF-1.4\n%âãÏÓ\n1 0 obj <</Filter/FlateDecode/Length 29>>stream\nx+är\ná26S°00S\bIár\rá\näâ

如何正确提取响应的两个部分? Python的电子邮件模块条款都不能很好地处理这些数据,它们都是一个大字符串。我期待的是:

MIME-Version: 1.0
Content-Type: Multipart/Related; boundary=_Part_2_27050467.1235668849951; type=text/xml;
        start="<some@domain.com>"
Content-Description: This is the optional message description.

在回复的开头,但只有那个进来。

0 个答案:

没有答案