suds (community fork)

1.2.0 · active · verified Tue Apr 14

Suds is a lightweight SOAP-based web service client for Python. This is a community fork of the `suds-jurko` fork, actively maintained to support modern Python versions (>=3.7). It provides an intuitive RPC-like interface to consume web services by objectifying WSDL-defined types without explicit class generation. The latest version is 1.2.0, released in August 2024, with a release cadence that has seen several updates in recent years.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a `suds` client, inspect available service methods, and invoke a simple SOAP operation using a publicly available temperature conversion WSDL. It also includes basic logging configuration essential for debugging SOAP interactions.

import logging
import os
from suds.client import Client

# Configure logging to see SOAP requests/responses for debugging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)

# A public WSDL for temperature conversion
wsdl_url = 'http://www.w3schools.com/xml/tempconvert.asmx?WSDL'

try:
    # Create a Suds client
    client = Client(wsdl_url)
    print(f"Connected to SOAP service at: {wsdl_url}")
    print("\nAvailable service methods:")
    print(client)

    # Invoke a method: FahrenheitToCelsius
    fahrenheit_temp = 68.0
    result = client.service.FahrenheitToCelsius(fahrenheit_temp)
    print(f"\n{fahrenheit_temp}°F is {result}°C")

    # Invoke another method: CelsiusToFahrenheit
    celsius_temp = 20.0
    result = client.service.CelsiusToFahrenheit(celsius_temp)
    print(f"{celsius_temp}°C is {result}°F")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Ensure the WSDL URL is correct and reachable, and that the service is active.")

view raw JSON →