from soaplib.serializers.primitive import Boolean, String from soaplib.service import DefinitionBase, rpc from soaplib.wsgi import Application from django.http import HttpResponse # the class with actual web methods class MySOAPService(DefinitionBase): @rpc(String, String, _returns=Boolean) def Test(self, f1, f2): return True # the class which acts as a wrapper between soaplib WSGI functionality and Django class DjangoSoapApp(Application): def __call__(self, request): # wrap the soaplib response into a Django response object django_response = HttpResponse() def start_response(status, headers): status, reason = status.split(' ', 1) django_response.status_code = int(status) for header, value in headers: django_response[header] = value response = super(DjangoSoapApp, self).__call__(request.META, start_response) django_response.content = '\n'.join(response) return django_response # the view to use in urls.py my_soap_service = DjangoSoapApp([MySOAPService], __name__)