Skip to main content

Convert any SOAP WSDL service to a REST API using FastAPI

Project description

soap2rest

Convert any SOAP WSDL service to a REST API using FastAPI.

Features

  • 🔄 Automatic Conversion: Automatically converts SOAP operations to REST endpoints
  • 🚀 FastAPI Powered: Built on FastAPI for high performance and automatic API documentation
  • 🔧 Zero Configuration: No manual endpoint configuration needed
  • 📚 Interactive Docs: Automatic Swagger/OpenAPI documentation at /docs
  • 🛡️ Error Handling: Proper HTTP status codes for SOAP faults, timeouts, and connection errors
  • Async Support: Non-blocking SOAP calls using thread pool execution

Installation

From Source

git clone https://github.com/yourusername/soap2rest.git
cd soap2rest
pip install .

From PyPI (when published)

pip install soap2rest

Quick Start

  1. Start the server with a WSDL URL:
soap2rest --wsdl https://www.dataaccess.com/webservicesserver/NumberConversion.wso?WSDL --port 8000
  1. View the API documentation:

Open http://localhost:8000/docs in your browser to see the interactive Swagger UI.

  1. Call the REST API:
curl -X POST http://localhost:8000/call/NumberToWords \
  -H "Content-Type: application/json" \
  -d '{"ubiNum": "123"}'

Usage

Basic Usage

soap2rest --wsdl <WSDL_URL> --port 8000

Advanced Options

soap2rest \
  --wsdl https://example.com/service.wsdl \
  --host 0.0.0.0 \
  --port 8000 \
  --workers 4 \
  --log-level info \
  --reload

Environment Variables

You can also configure the server using environment variables:

export SOAP2REST_WSDL="https://example.com/service.wsdl"
export SOAP2REST_PORT=8000
export SOAP2REST_HOST="0.0.0.0"
export SOAP2REST_WORKERS=4
export SOAP2REST_LOG_LEVEL="info"
export SOAP2REST_RELOAD="true"

soap2rest

Command Line Options

  • --wsdl (required): WSDL URL or file path
  • --host (default: 0.0.0.0): Host to bind to
  • --port (default: 8000): Port to bind to
  • --workers (default: 1): Number of worker processes
  • --log-level (default: info): Logging level (critical, error, warning, info, debug, trace)
  • --reload (default: false): Enable auto-reload for development
  • --timeout-keep-alive (default: 5): Keep-alive timeout in seconds

How It Works

  1. WSDL Parsing: The tool loads and parses the WSDL file/URL
  2. Operation Discovery: Automatically discovers all SOAP operations
  3. REST Endpoint Generation: Creates REST endpoints for each SOAP operation
  4. Dynamic Model Creation: Generates Pydantic models for request validation
  5. Request Processing: Converts REST requests to SOAP calls and returns JSON responses

Example

Given a SOAP service with operation NumberToWords, the tool automatically creates:

  • GET / - Lists all available operations
  • POST /call/NumberToWords - REST endpoint for the SOAP operation

Request:

POST /call/NumberToWords
{
  "ubiNum": "123"
}

Response:

{
  "result": "one hundred and twenty three "
}

Development

Setting Up Development Environment

git clone https://github.com/yourusername/soap2rest.git
cd soap2rest
pip install -e ".[dev]"

Running Tests

pytest

Building the Package

python -m build

Publishing to PyPI

python -m build
python -m twine upload dist/*

Requirements

  • Python 3.8+
  • FastAPI
  • Uvicorn
  • Zeep (SOAP client)
  • Pydantic
  • AnyIO

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

soap2rest-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

soap2rest-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file soap2rest-0.1.0.tar.gz.

File metadata

  • Download URL: soap2rest-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for soap2rest-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dda76e2102fa2256c66aea368854a17f5cf9e807c7a2b489dce59749da80d68a
MD5 421e3e4a58b20972ab94c22aad1c2e3f
BLAKE2b-256 1d81674f9deecc7f4b175db3416417c437013a534e67d781d5239f3e67f7fecb

See more details on using hashes here.

File details

Details for the file soap2rest-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: soap2rest-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for soap2rest-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfa25a438ba1a637de53b2c4f6051315410274b3d46692630ede2f0dc72d4c5e
MD5 3983aeef950c9eee070f822307e67117
BLAKE2b-256 4de749f1609cf7b086eac80cf349a1874fc889f9bc7632c5e8a7f28b4ec8f28f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page