Login

SOAP web service with soaplib 2.0

Author:
treyh
Posted:
January 3, 2012
Language:
Python
Version:
1.3
Tags:
soap soaplib wsdl
Score:
0 (after 0 ratings)

I've updated the DjangoSoapApp class from this popular soaplib snippet so the snippet will work properly with soaplib 2.0.

Usage is the same as before:

my_soap_service = DjangoSoapApp([MySOAPService], __name__)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from soaplib.core import Application
from soaplib.core.server.wsgi import Application as WSGIApplication
from django.http import HttpResponse


class DjangoSoapApp(WSGIApplication):
    """
    Generic Django view for creating SOAP web services (works with soaplib 2.0)

    Based on http://djangosnippets.org/snippets/2210/
    """

    csrf_exempt = True

    def __init__(self, services, tns):
        """Create Django view for given SOAP soaplib services and tns"""

        return super(DjangoSoapApp, self).__init__(Application(services, tns))

    def __call__(self, request):
        django_response = HttpResponse()

        def start_response(status, headers):
            django_response.status_code = int(status.split(' ', 1)[0])
            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

More like this

  1. Convert django model into soaplib model, to expose webservices by s.federici 6 years, 6 months ago
  2. SOAP web service with soaplib 0.9+ by wRAR 4 years, 10 months ago
  3. django soaplib test client by erny 6 years, 4 months ago
  4. SOAP views with on-demand WSDL generation by chewie 6 years, 11 months ago
  5. soaplib service integration 2 by erny 6 years, 4 months ago

Comments

arasusara (on November 8, 2013):

I've seen this soaplib plugin does not evolve or documented properly. So failed!!!

#

Please login first before commenting.