Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using server let to a TypeError #116

Open
bene42 opened this issue Jan 20, 2016 · 1 comment
Open

using server let to a TypeError #116

bene42 opened this issue Jan 20, 2016 · 1 comment

Comments

@bene42
Copy link

bene42 commented Jan 20, 2016

Using a list or dict as return of a SOAP method let to an error:
File "pysimplesoap/server.py", line 372, in parse_element
if v in TYPE_MAP.keys():
TypeError: unhashable type: 'list'

Reoder the type check and add a comment to avoid this error.

server:

from pysimplesoap.server import SoapDispatcher, SOAPHandler
from http.server import HTTPServer

def getlist():
    "Return a list"
    return {'list': [{'col': 'A'}, {'col': 'B'}, {'col': 'C'}]}

dispatcher = SoapDispatcher(
        'my_dispatcher',
        location = "http://localhost:8008/",
        action = 'http://localhost:8008/', # SOAPAction
        namespace = "http://example.com/sample.wsdl", prefix="ns0",
        trace = True,
        ns = True)

# register the user function
dispatcher.register_function('GetList', getlist,
                             returns = {'list': [{'col': str}]},
                             args = {})

print ("Starting server...")
httpd = HTTPServer(("", 8008), SOAPHandler)
httpd.dispatcher = dispatcher
httpd.serve_forever()

client:

from suds.client import Client

client = Client ("http://127.0.0.1:8008/")
result = client.service.GetList ()
print result

0001-reorder-type-check-to-avoid-a-TypeError.txt

@oldium
Copy link

oldium commented May 15, 2018

I just faced the same issue, solution is in pull request #163.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants