1

I'm trying to create a method to use suds.client from suds-py3 with the next form:

from suds.client import Client

def soap_request(url, parameter, request_dictionary, method)
    client = Client(url)
    parameter_object = client.factory.create(str(parameter))
    for var, value in request_dictionary.items():
        parameter_object[str(var)] = value
    request_response = client.service.method(parameter_object)
    return = request_response

When i use:

client.service.<methods_name>(parameter_object)

I get the response correctly. But when i use the previous code, i get this error message: "suds.MethodNotFound: Method not found"

Simon Capriles
  • 143
  • 2
  • 21

2 Answers2

0

I´ve managed to do this thanks to this answer https://stackoverflow.com/a/1855575/12059030 so, the result code would be:

from suds.client import Client

def soap_request(url, parameter, request_dictionary, method):
    client = Client(url)
    parameter_object = client.factory.create(str(parameter))
    for var, val in request_dictionary.items():
        parameter_object[str(var)] = val
    request_response = getattr(client.service, method)()
    return request_response

If someone has a better solution, it is very welcome

Simon Capriles
  • 143
  • 2
  • 21
0

There is a missing variable in the previous code, so the complete code would be the following:

from suds.client import Client

def soap_request(url, parameter, request_dictionary, method):
    client = Client(url)
    parameter_object = client.factory.create(str(parameter))
    for var, val in request_dictionary.items():
        parameter_object[str(var)] = val
    request_response = getattr(client.service, method)(parameter_object)
    return request_response

As you can notice, the "parameter_object" was missing in the "request_response".

Simon Capriles
  • 143
  • 2
  • 21