The popular soaplib snippet works only with older soaplib (0.8, for example). This snippet is modifed to work with newer soaplib: it was tested with 0.9.2-alpha3 and 1.0.0-beta4. I've tested suds python client and .NET client.
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
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__)
More like this
- Stuff by NixonDash 1 month ago
- Add custom fields to the built-in Group model by jmoppel 3 months, 1 week ago
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 6 months, 3 weeks ago
- Python Django CRUD Example Tutorial by tuts_station 7 months ago
- Browser-native date input field by kytta 8 months, 3 weeks ago
nice snippet, but I catch 403 "CSRF token missing or incorrect." any ideas to solve it?
Try this to get around csrf protection:
Please login first before commenting.