ombre42 / robotframework-sudslibrary

Web service testing library for Robot Framework
Apache License 2.0
29 stars 44 forks source link

AssertionError [proxy.py] #32

Open mayribeirofernandes opened 5 years ago

mayribeirofernandes commented 5 years ago

Hi!!

I'm using:

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

MohammadOmairDar commented 4 years ago

So you converted the message into bytes and then passed it?

mayribeirofernandes commented 4 years ago

So you converted the message into bytes and then passed it?

Yes.

MohammadOmairDar commented 4 years ago

Darn doesn't work for me!

bruindav commented 4 years ago

Hi I tried your solution but get message NameError: name 'byte_str' is not defined

Do I need more ?

ghaleda commented 4 years ago

@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