Login

SOAP web service with soaplib 2.0

Author:
treyh
Posted:
January 3, 2012
Language:
Python
Version:
1.3
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. Template tag - list punctuation for a list of items by shapiromatron 10 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
  5. Help text hyperlinks by sa2812 1 year, 6 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.