django wrapper for rpclib
# coding: utf-8 | |
# Fork of https://gist.github.com/1242760 | |
from django.http import HttpResponse | |
from rpclib.server.wsgi import WsgiApplication | |
class DjangoApplication(WsgiApplication): | |
def __call__(self, request): | |
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 | |
environ = request.META.copy() | |
environ['wsgi.input'] = request | |
environ['wsgi.multithread'] = False | |
response = WsgiApplication.__call__(self, environ, start_response) | |
django_response.content = "\n".join(response) | |
return django_response |
from rpclib.server.django import DjangoApplication # not real import path. | |
from rpclib.service import ServiceBase | |
from rpclib.interface.wsdl import Wsdl11 | |
from rpclib.protocol.soap import Soap11 | |
from rpclib.application import Application | |
class HelloWorldService(ServiceBase): | |
@soap(String, Integer, _returns=Iterable(String)) | |
def say_hello(self, name, times): | |
for i in xrange(times): | |
yield 'Hello, %s' % name | |
hello_world_service = DjangoApplication(Application([HelloWorldService], | |
'some.tns', | |
interface=Wsdl11(), | |
in_protocol=Soap11(), | |
out_protocol=Soap11() | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment