suds-community / suds

Suds is a lightweight SOAP python client for consuming Web Services. A community fork of the jurko fork.
https://suds.readthedocs.io/
GNU Lesser General Public License v3.0
172 stars 54 forks source link

Suds returning method instead of value #62

Closed SupreetBose closed 2 years ago

SupreetBose commented 2 years ago

I am attempting to connect SOAP API with Python. I am using Py3.9 version. I am using a simple method that returns the time on server and we don't need to pass any parameter ,as shown below:

servertime() If I use SOAP UI for the method I can get the values directly in XML hour, minute , timezone etc. Code :

from suds.client import Client
operation_OA = Client("server-address/wsdl.pl?")
server_time = getattr(operation_OA.service, "servertime")
print(server_time())

I get the below error: suds.TypeNotFound: Type not found: 'timezone' Can anyone suggest.

Going through all the logs I found out that somehow the server_time() returns a method . (Just to understand I used a For loop). My understanding is that it would return the output of a method instead.

for oa in server_time:
    print(oa)

This is what I get : TypeError: 'Method' object is not iterable. What am I missing ?

phillbaker commented 2 years ago

Hi @SupreetBose have you taken a look at the basic usage section of the README?

I'd suggest inspecting the service similarly to:

from suds.client import Client
url = 'server-address/wsdl.pl?'
client = Client(url)
print(client)

Likely your service can be called similarly to:

from suds.client import Client
url = 'server-address/wsdl.pl?'
client = Client(url)
client.service.server_time()

Simple arguments can be passed directly to the method, complex arguments will have to be created.

In general, unless you can provide access to the specific WSDL in question, it's hard to provide more than general answers.

SupreetBose commented 2 years ago

Hello @phillbaker , Thank you for your response. I tried the above code client.service.method_name() it threw the below error : _suds.MethodNotFound: Method not found: 'HandlerService.Service.method_name'_

Tried with a different method name also This is the basic structure that is there in WSDL in case if this gives some hint as to what I should do :

<wsdl:message name="**method_name**">
<wsdl:part name="servertimeReturn" type="tns1:DateDatatype">
<wsdl:documentation>Returns current servertime Date object.</wsdl:documentation>
</wsdl:part>
</wsdl:message>
<wsdl:message name="**method_name**"> </wsdl:message>

As for the README file I have already gone through but will go through again in case I missed out something. Let me know if I am missing something obvious.

phillbaker commented 2 years ago

In order to investigate this further, we'll need the following:

Note: if these can't be provided, we'll have to close this issue. I see you also asked on stackoverflow, that may be a more appropriate place for this question.

phillbaker commented 2 years ago

I'm going to close this issue for now. Please re-open if if you can provide the information above.