Skip to main content

No project description provided

Project description

FastAPI Soap

This package helps to create Soap WebServices using FastAPI (What?!?!)

Motivation

I know, FastAPI is a REST micro framework, but sometimes is needed to expose a Soap Interface on a already running FastAPI application for an legacy client/application that only supports, well, the Soap protocol...

Installation and dependencies

Only FastAPI, Pydantic and Pydantic XML are required.

First steps

from fastapi import FastAPI
from fastapi_soap.models import BodyContent


class Operands(BodyContent, tag="Operands"):
    operands: list[float] = element(tag="Operand")

class Result(BodyContent, tag="Result"):
    value: float

soap = SoapRouter(name='Calculator', prefix='/Calculator')

@soap.operation(
    name="SumOperation",
    request_model=Operands,
    response_model=Result
)
def sum_operation(body: Operands = XMLBody(Operands)):
    result = sum(body.operands)
    
    return SoapResponse(
        Result(value=result)
    )


app = FastAPI()
app.include_router(soap)

if __name__ == '__main__':
    import uvicorn
    uvicorn.run("example.main:app")

(This script is complete, it should run "as is")

The WSDL is available on webservice root path for GET method.

GET http://localhost:8000/Calculator/

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

fastapi-soap-0.0.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

fastapi_soap-0.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file fastapi-soap-0.0.2.tar.gz.

File metadata

  • Download URL: fastapi-soap-0.0.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.10.6 Darwin/21.6.0

File hashes

Hashes for fastapi-soap-0.0.2.tar.gz
Algorithm Hash digest
SHA256 88711390c74ae8e8c6217853398a6271b635f1239d6786a153baea78d8442784
MD5 5df40ae203adae9ea4b40c559d336947
BLAKE2b-256 a124f6ed3cd02e8ddd802330f836da25b2c1e6bbac78a633dff4083f4ec0a976

See more details on using hashes here.

File details

Details for the file fastapi_soap-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: fastapi_soap-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.10.6 Darwin/21.6.0

File hashes

Hashes for fastapi_soap-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0706143c70a08c8f4681271d18447e850081fb0c132841b4b6c3e22cbed5fded
MD5 8d794272e70f55e6d409c018292abb5d
BLAKE2b-256 72668d93d60cb2c8f7672bf412fbc1daf6f30e2998fd73eec657d8708638d5da

See more details on using hashes here.

Supported by

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