SOAP响应只给我1%的文件内容

时间:2019-01-14 22:33:14

标签: python soap soapui zeep

我有一个非常简单的SOAP请求,正在发送到服务器。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:RetrieveDocRequest>
         <F_FOLDER>folderName</F_FOLDER>
         <F_USER>userName</F_USER>
         <F_PASSWORD>psw</F_PASSWORD>
         <F_DOC_ID>111222333</F_DOC_ID>
      </web:RetrieveDocRequest>
   </soapenv:Body>
</soapenv:Envelope>

我期望的响应是大约 35 MB 的文件。相反,我收到的内容如下所示。

Transfer-Encoding   chunked
#status#    HTTP/1.1 200 OK
Content-Language    en-US
Date    Fri, 11 Dec 2018 19:45:17 GMT
X-Powered-By    Servlet/3.0
Content-Type    text/xml; charset=UTF-8

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <a:RetrieveCompanyResponse xmlns:a="http://somewebservice.company.morecompany.com/">
            <documentStream>AF3xQEBAQEBAQEBAQEBA...</documentStream>
        <a:RetrieveCompanyResponse>
    </soap:Body>
</soap:Envelope>

当我使用python解析documentStream并将其写入文件时,我注意到该文件约为 350 KB ,这意味着我仍然缺少该文件的99%。

>

我可以对SOAP请求做任何事情来允许我下载整个文件,还是不断向我发送多个我可以写入临时文件的documentStream吗?

还有,我有什么特别做错的事情,例如不发送某些标头?

编辑:Python示例代码

from zeep import Client
import codecs

wsdl = "http://webservice/service/ServicesPort?wsdl"
f = open('tmpFile.txt', 'wb')

client = Client(wsdl)

result = client.service.RetrieveDoc(
    'folderName',
    'userName',
    'psw',
    '111222333'
)

print len(result) # Ends up being around 240,394
tmpTxt = codecs.decode(result, 'cp500')
tmpTxt = tmpTxt.encode('utf-8')
txtArr = tmpTxt.split('\x00')
# Writes about 350 KB worth of data
for line in txtArr:
    f.write(line)

0 个答案:

没有答案