2017-01-30 101 views
1

我想從官方的pip倉庫中使用jurko(Python 3.5.2)發出一些使用泡沫的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 

從回溯,我的理解是什麼錯誤,但我想不出什麼原因造成的。有什麼建議麼?

注:此請求是俄羅斯郵政API請求,所有需要採取​​

+0

我還沒有足夠的信譽發表評論,但我發現皁液的庫頁上的這種情況。它是一個[bug](https://bitbucket.org/jurko/suds/issues/106/assertionerror) –

回答

0

我一段時間後,再次運行到這個問題,這似乎是與編碼問題。我將CentOS上的語言環境設置爲「ru_RU.utf-8」,一切開始正常。

0

這應該可以解決這個問題:

from suds import byte_str 
message = byte_str(message)