Warning: include_once(/home/favoledo/robertozanardo.com/wp-content/sunrise.php): Failed to open stream: No such file or directory in /home/favoledo/robertozanardo.com/wp-includes/ms-settings.php on line 52

Warning: include_once(): Failed opening '/home/favoledo/robertozanardo.com/wp-content/sunrise.php' for inclusion (include_path='.:/opt/alt/php83/usr/share/pear:/opt/alt/php83/usr/share/php:/usr/share/pear:/usr/share/php') in /home/favoledo/robertozanardo.com/wp-includes/ms-settings.php on line 52
Accedere ai webservice soap con suds in Python

Accedere ai webservice soap con suds in Python

Accedere ai webservice con suds in Python

Installare suds per python 3

Il metodo più semplice è il fidato pip:

pip install suds-py3

Elencare i servizi disponibili

from suds.client import Client

client = Client("https://www.testfe.com/test_service.asmx?WSDL")

print(client)

Impostare lo schema

per alcuni tipi di servizio può essere necessario specificare lo schema.

from suds.xsd.doctor import Import, ImportDoctor

imp=Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://tempuri.org/')

Esempio completo

from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor

imp=Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://tempuri.org/')

client = Client("https://www.testfe.com/test_service.asmx?WSDL", doctor=ImportDoctor(imp))
#print(client) #Qui possiamo far stampare tutti i metodi disponibili, tra cui troveremo il nostro: TestMethod()

result = client.service.TestMethod()
print (result)

Lascia un commento