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
- Start the server with a WSDL URL:
soap2rest --wsdl https://www.dataaccess.com/webservicesserver/NumberConversion.wso?WSDL --port 8000
- View the API documentation:
Open http://localhost:8000/docs in your browser to see the interactive Swagger UI.
- 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
- WSDL Parsing: The tool loads and parses the WSDL file/URL
- Operation Discovery: Automatically discovers all SOAP operations
- REST Endpoint Generation: Creates REST endpoints for each SOAP operation
- Dynamic Model Creation: Generates Pydantic models for request validation
- 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 operationsPOST /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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dda76e2102fa2256c66aea368854a17f5cf9e807c7a2b489dce59749da80d68a
|
|
| MD5 |
421e3e4a58b20972ab94c22aad1c2e3f
|
|
| BLAKE2b-256 |
1d81674f9deecc7f4b175db3416417c437013a534e67d781d5239f3e67f7fecb
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa25a438ba1a637de53b2c4f6051315410274b3d46692630ede2f0dc72d4c5e
|
|
| MD5 |
3983aeef950c9eee070f822307e67117
|
|
| BLAKE2b-256 |
4de749f1609cf7b086eac80cf349a1874fc889f9bc7632c5e8a7f28b4ec8f28f
|