robotframework-sudslibrary
robotframework-sudslibrary copied to clipboard
AssertionError [proxy.py]
Hi!!
I'm using: - Python 3.7.2 - robotframework-sudslibrary-aljcalandra==1.1
My Robot code:
Enviar requisição SOAP
Create Soap Client ${WSDL_URL}
${MESSAGE} Get File consultaProcesso_envio.xml
${MESSAGE} Create Raw Soap Message ${MESSAGE}
Log ${MESSAGE}
${RESPONSE} Call Soap Method consultarProcesso ${MESSAGE}
${RESPONSE_XML} Get Last Received
When i have tried to execute then, the following error occurs in Call Soap Method:
File "c:\users\mayara.fernandes\appdata\local\programs\python\python37-32\lib\site-packages\SudsLibrary\proxy.py", line 46, in call_soap_method
return self._call(None, None, False, name, *args)
File "c:\users\mayara.fernandes\appdata\local\programs\python\python37-32\lib\site-packages\SudsLibrary\proxy.py", line 105, in _call
received = method(__inject={'msg': args[0].message})
File "c:\users\mayara.fernandes\appdata\local\programs\python\python37-32\lib\site-packages\suds\client.py", line 521, in __call__
return client.invoke(args, kwargs)
File "c:\users\mayara.fernandes\appdata\local\programs\python\python37-32\lib\site-packages\suds\client.py", line 761, in invoke
assert msg.__class__ is suds.byte_str_class
I solved the problem by making an adjustment in proxy.py:
Original Code:
if len(args) == 1 and isinstance(args[0], RawSoapMessage):
received = method(__inject={'msg': args[0].message})
Code with my adjustment:
if len(args) == 1 and isinstance(args[0], RawSoapMessage):
message = byte_str(args[0].message)
received = method(__inject={'msg': message})
Could you evaluate this adjustment, was it the best way to solve it?
Thanks. May Fernandes
So you converted the message into bytes and then passed it?
So you converted the message into bytes and then passed it?
Yes.
Darn doesn't work for me!
Hi I tried your solution but get message NameError: name 'byte_str' is not defined
Do I need more ?
@bruindav I received same error as you did. I then used the .encode() rather to encode string to bytes as per below: if len(args) == 1 and isinstance(args[0], RawSoapMessage): message = args[0].message.encode() received = method(__inject={'msg': message})
Then in robot framework I had to decode the response as
${sendmessage} Call Soap Method *YourServiceMethod* ${message}
${checkresponse} Get Last Received
${checkresponseDecoded} Decode Bytes To String ${checkresponse} UTF-8
This worked for me