我正在尝试使用jurko的suds (Python3.5.2)从官方的pip存储库发送一些SOAP。
这是我的密码。不幸的是,我应该隐藏我的登录和密码,所以你不能只是复制和粘贴到你的终端。
my_login = 'login'
my_password = 'password'
barcode = '10100082848426'
message = \
"""<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:oper="http://russianpost.org/operationhistory" xmlns:data="http://russianpost.org/operationhistory/data" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<oper:getOperationHistory>
<data:OperationHistoryRequest>
<data:Barcode>""" + barcode+ """</data:Barcode>
<data:MessageType>0</data:MessageType>
<data:Language>RUS</data:Language>
</data:OperationHistoryRequest>
<data:AuthorizationHeader soapenv:mustUnderstand="1">
<data:login>"""+ my_login +"""</data:login>
<data:password>""" + my_password + """</data:password>
</data:AuthorizationHeader>
</oper:getOperationHistory>
</soap:Body>
</soap:Envelope>"""
result = client.service.getOperationHistory(__inject={'msg':message})在这里我得到一个错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/suds/client.py", line 521, in __call__
return client.invoke(args, kwargs)
File "/usr/local/lib/python3.5/site-packages/suds/client.py", line 760, in invoke
assert msg.__class__ is suds.byte_str_class
AssertionError通过追溯,我理解了错误是什么,但我不知道是什么原因造成的。有什么建议吗?
注意:这个请求是一个俄罗斯Post API请求,所有需要采取这里
发布于 2017-04-29 18:27:14
过了一段时间,我又遇到了这个问题,这似乎是编码方面的问题。我将CentOS上的区域设置为"ru_RU.utf-8“,一切都开始正常工作。
发布于 2017-07-10 08:51:30
这应能解决以下问题:
from suds import byte_str
message = byte_str(message)https://stackoverflow.com/questions/41936558
复制相似问题