我有一个非常简单的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>
我期望得到的响应是一个大约35MB的文件。相反,我收到的是如下所示。你知道吗
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并将其写入一个文件时,我注意到该文件约为350kb,这意味着我仍然缺少约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)
目前没有回答
相关问题 更多 >
编程相关推荐