Metadata-Version: 2.4
Name: soap2rest
Version: 0.1.0
Summary: Convert any SOAP WSDL service to a REST API using FastAPI
Author-email: Ashish <you@example.com>
Maintainer-email: Ashish <you@example.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/yourusername/soap2rest
Project-URL: Documentation, https://github.com/yourusername/soap2rest#readme
Project-URL: Repository, https://github.com/yourusername/soap2rest
Project-URL: Issues, https://github.com/yourusername/soap2rest/issues
Project-URL: Bug Tracker, https://github.com/yourusername/soap2rest/issues
Keywords: soap,rest,api,wsdl,fastapi,conversion,web-service,http,soap-to-rest
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Framework :: FastAPI
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi<1.0,>=0.104.0
Requires-Dist: uvicorn[standard]<1.0,>=0.24.0
Requires-Dist: zeep<5.0,>=4.2.0
Requires-Dist: pydantic<3.0,>=2.0.0
Requires-Dist: anyio<4.0,>=3.0.0
Requires-Dist: requests>=2.28.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: httpx>=0.24.0; extra == "dev"
Requires-Dist: build>=0.10.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Dynamic: license-file

# 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

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

### From PyPI (when published)

```bash
pip install soap2rest
```

## Quick Start

1. **Start the server** with a WSDL URL:

```bash
soap2rest --wsdl https://www.dataaccess.com/webservicesserver/NumberConversion.wso?WSDL --port 8000
```

2. **View the API documentation**:

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

3. **Call the REST API**:

```bash
curl -X POST http://localhost:8000/call/NumberToWords \
  -H "Content-Type: application/json" \
  -d '{"ubiNum": "123"}'
```

## Usage

### Basic Usage

```bash
soap2rest --wsdl <WSDL_URL> --port 8000
```

### Advanced Options

```bash
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:

```bash
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:
```json
POST /call/NumberToWords
{
  "ubiNum": "123"
}
```

Response:
```json
{
  "result": "one hundred and twenty three "
}
```

## Development

### Setting Up Development Environment

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

### Running Tests

```bash
pytest
```

### Building the Package

```bash
python -m build
```

### Publishing to PyPI

```bash
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](https://github.com/yourusername/soap2rest/issues).
