Example #1
0
def build_app(service_list, tns, name):
    app = Application(service_list,
                      tns,
                      Wsdl11(),
                      Soap11(),
                      Soap11(),
                      name=name)
    app.transport = 'http://schemas.xmlsoap.org/soap/http'
    return app
Example #2
0
    def test_multiple_return(self):
        class SomeNotSoComplexModel(ComplexModel):
            s = String

        class SomeService(ServiceBase):
            @srpc(_returns=[Integer, String])
            def some_call():
                return 1, 's'

        app = Application([SomeService], 'tns', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(app, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
        }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(app)
        try:
            ctx, = server.generate_contexts(initial_ctx)
            server.get_in_object(ctx)
            server.get_out_object(ctx)
            server.get_out_string(ctx)
        except ValueError:
            pass
        else:
            raise Exception("Must Fail")
Example #3
0
    def test_primitive_only(self):
        class SomeComplexModel(ComplexModel):
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(SomeComplexModel, _returns=SomeComplexModel)
            def some_call(scm):
                return SomeComplexModel(i=5, s='5x')

        app = Application([SomeService], 'tns', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(app, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
        }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(app)

        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        print "!", ctx.in_object
        server.get_out_object(ctx)

        try:
            server.get_out_string(ctx)
        except:
            pass
        else:
            raise Exception("Must Fail")
Example #4
0
    def test_complex(self):
        class CM(ComplexModel):
            i = Integer
            s = String

        class CCM(ComplexModel):
            c = CM
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(CCM, _returns=CCM)
            def some_call(ccm):
                return CCM(c=ccm.c, i=ccm.i, s=ccm.s)

        app = Application([SomeService], 'tns', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(app, {
            'QUERY_STRING': '',
            'PATH_INFO': '/some_call',
        }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(app)
        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)
Example #5
0
    def test_basic(self):
        class SomeService(ServiceBase):
            @srpc(String(pattern='a'))
            def some_method(s):
                pass

        application = Application(
            [SomeService],
            interface=Wsdl11(),
            in_protocol=Soap11(validator='soft'),
            out_protocol=Soap11(),
            name='Service',
            tns='tns',
        )

        ctx = MethodContext(application)
        ctx.in_string = [
            u"""
            <SOAP-ENV:Envelope xmlns:ns0="tns"
                               xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
               <SOAP-ENV:Body>
                  <ns0:some_method>
                     <ns0:s>OK</ns0:s>
                  </ns0:some_method>
               </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>
        """
        ]

        from rpclib.server import ServerBase

        server = ServerBase(application)
        server.get_in_object(ctx)

        self.assertEquals(isinstance(ctx.in_error, ValidationError), True)
Example #6
0
    def setUp(self):
        self.app = Application([TestService], 'tns', Wsdl11(), Soap11(),
                               Soap11())
        self.srv = TestService()

        self.app.interface.build_interface_document('URL')
        self.wsdl_str = self.app.interface.get_interface_document()
        self.wsdl_doc = etree.fromstring(self.wsdl_str)
Example #7
0
    def test_single_method(self):
        try:
            app = Application([MultipleMethods1, MultipleMethods2], 'tns',
                              Wsdl11(), Soap11(), Soap11())
            app.interface.build_interface_document('url')
            raise Exception('must fail.')

        except ValueError:
            pass
Example #8
0
    def __get_binding_application(self, binding_service):
        '''Builds an instance of rpclib.Application

        The Application built is populated with an instance of a Service Class
        based on ServiceBase
        @param A class based on ServiceBase
        '''

        binding_application = Application([binding_service],
                                          rpclib.interface.wsdl.Wsdl11,
                                          rpclib.protocol.soap.Soap11,
                                          tns='binding_application')

        # The lxml Element nsmap is being overridden to remove the unneeded
        # namespaces
        binding_application.nsmap = XSDGenerator.model_schema_nsmap
        binding_application.prefmap = \
                dict([(b,a) for a,b in XSDGenerator.model_schema_nsmap.items()])

        binding_application.call_routes = {}

        return binding_application
Example #9
0
def wsgi_soap11_application(services,
                            tns='rpclib.simple.soap',
                            validator=None):
    """Wraps `services` argument inside a WsgiApplication that uses Wsdl 1.1 as
    interface document and Soap 1.1 and both input and output protocols.
    """

    application = Application(services,
                              tns,
                              interface=Wsdl11(),
                              in_protocol=Soap11(validator=validator),
                              out_protocol=Soap11())

    return WsgiApplication(application)
Example #10
0
    def test_call(self):
        queue = set()

        class MessageService(ServiceBase):
            @srpc(String)
            def send_message(s):
                queue.add(s)

        application = Application([MessageService], 'some_tns',
            interface=Wsdl11(), in_protocol=Soap11(), out_protocol=Soap11())

        server = NullServer(application)
        server.service.send_message("zabaaa")

        assert set(["zabaaa"]) == queue
Example #11
0
    def setUp(self):
        class SomeService(ServiceBase):
            @srpc(String(pattern='a'))
            def some_method(s):
                pass

            @srpc(String(pattern='a', max_occurs=2))
            def some_other_method(s):
                pass

        self.application = Application(
            [SomeService],
            interface=Wsdl11(),
            in_protocol=HttpRpc(validator='soft'),
            out_protocol=Soap11(),
            name='Service',
            tns='tns',
        )
Example #12
0
    def test_multiple_methods(self):
        in_protocol = Soap11()
        out_protocol = Soap11()

        # for the sake of this test.
        in_protocol.supports_fanout_methods = True
        out_protocol.supports_fanout_methods = True

        app = Application([MultipleMethods1, MultipleMethods2],
                          'tns',
                          Wsdl11(),
                          in_protocol,
                          out_protocol,
                          supports_fanout_methods=True)
        app.interface.build_interface_document('url')

        mm = app.interface.service_method_map['{tns}multi']

        def find_class_in_mm(c):
            found = False
            for s, _ in mm:
                if s is c:
                    found = True
                    break

            return found

        assert find_class_in_mm(MultipleMethods1)
        assert find_class_in_mm(MultipleMethods2)

        def find_function_in_mm(f):
            i = 0
            found = False
            for _, d in mm:
                i += 1
                if d.function is f:
                    found = True
                    print i
                    break

            return found

        assert find_function_in_mm(MultipleMethods1.multi)
        assert find_function_in_mm(MultipleMethods2.multi)
Example #13
0
    def test_fanout(self):
        arr = set()

        class MessageService1(ServiceBase):
            @srpc()
            def send_message():
                arr.add(1)

        class MessageService2(ServiceBase):
            @srpc()
            def send_message():
                arr.add(2)

        application = Application([MessageService1,MessageService2], 'some_tns',
            interface=Wsdl11(), in_protocol=Soap11(), out_protocol=Soap11(),
            supports_fanout_methods=True)

        server = NullServer(application)
        server.service.send_message()

        assert set([1,2]) == arr
Example #14
0
    def test_nested_flatten(self):
        class CM(ComplexModel):
            i = Integer
            s = String

        class CCM(ComplexModel):
            c = CM
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(CCM, _returns=String)
            def some_call(ccm):
                return repr(ccm)

        app = Application([SomeService], 'tns', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(
            app, {
                'QUERY_STRING': 'ccm_i=1&ccm_s=s&ccm_c_i=3&ccm_c_s=cs',
                'PATH_INFO': '/some_call',
            }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(app)
        ctx, = server.generate_contexts(initial_ctx)

        server.get_in_object(ctx)
        assert ctx.in_error is None

        server.get_out_object(ctx)
        assert ctx.out_error is None

        server.get_out_string(ctx)

        print ctx.out_string
        assert ctx.out_string == ["CCM(i=1, c=CM(i=3, s='cs'), s='s')"]
Example #15
0
    def test_wsdl(self):
        app = Application(
            [TestService],
            'tns',
            rpclib.interface.wsdl.Wsdl11(),
            rpclib.protocol.soap.Soap11(),
            rpclib.protocol.soap.Soap11(),
        )

        app.interface.build_interface_document('punk')
        wsdl = app.interface.get_interface_document()

        elt = etree.fromstring(wsdl)
        simple_type = elt.xpath('//xs:simpleType',
                                namespaces=app.interface.nsmap)[0]

        print(etree.tostring(elt, pretty_print=True))
        print(simple_type)

        self.assertEquals(simple_type.attrib['name'], 'DaysOfWeekEnum')
        self.assertEquals(simple_type[0].tag, "{%s}restriction" % _ns_xsd)
        self.assertEquals([e.attrib['value'] for e in simple_type[0]], vals)
Example #16
0
    def test_nested_flatten_with_multiple_values_2(self):
        class CM(ComplexModel):
            i = Integer
            s = String

        class CCM(ComplexModel):
            c = CM.customize(max_occurs=2)
            i = Integer
            s = String

        class SomeService(ServiceBase):
            @srpc(CCM, _returns=String)
            def some_call(ccm):
                return repr(ccm)

        app = Application([SomeService], 'tns', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(
            app, {
                'QUERY_STRING': 'ccm_i=1&ccm_s=s&ccm_c_i=3&ccm_c_s=cs',
                'PATH_INFO': '/some_call',
            }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(app)
        ctx, = server.generate_contexts(initial_ctx)

        try:
            server.get_in_object(ctx)
        except:
            pass
        else:
            raise Exception(
                "Must fail with: Exception: HttpRpc deserializer "
                "does not support non-primitives with max_occurs > 1")
Example #17
0
    def test_multiple(self):
        class SomeService(ServiceBase):
            @srpc(String(max_occurs='unbounded'), _returns=String)
            def some_call(s):
                return '\n'.join(s)

        app = Application([SomeService], 'tns', Wsdl11(), HttpRpc(), HttpRpc())

        from rpclib.server.wsgi import WsgiMethodContext

        initial_ctx = WsgiMethodContext(app, {
            'QUERY_STRING': 's=1&s=2',
            'PATH_INFO': '/some_call',
        }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(app)
        ctx, = server.generate_contexts(initial_ctx)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)

        assert ctx.out_string == ['1\n2']
Example #18
0
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
#

import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('rpclib.protocol.xml').setLevel(logging.DEBUG)
logger = logging.getLogger('rpclib.test.interop.server.soap_http_basic')

from rpclib.server.wsgi import WsgiApplication
from rpclib.test.interop.server._service import services
from rpclib.application import Application
from rpclib.protocol.soap import Soap11
from rpclib.interface.wsdl import Wsdl11

soap_application = Application(services, 'rpclib.test.interop.server',
                               Wsdl11(), Soap11(validator='lxml'), Soap11())

if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
        from wsgiref.validate import validator

        wsgi_application = WsgiApplication(soap_application)
        server = make_server('0.0.0.0', 9753, validator(wsgi_application))

        logger.info('Starting interop server at %s:%s.' % ('0.0.0.0', 9753))
        logger.info('WSDL is at: /?wsdl')
        server.serve_forever()

    except ImportError:
        print("Error: example server code requires Python >= 2.5")
Example #19
0
    if "session-id" not in cookie:
        raise UnauthenticatedError()
    session_cookie = cookie["session-id"].value
    session_id = tuple(base64.urlsafe_b64decode(session_cookie).split("\0", 1))
    if not session_id in session_db:
        raise AuthenticationError(session_id[0])
    ctx.udc = session_id[0]     # user name
    

UserService.event_manager.add_listener('method_call', _on_method_call)

if __name__=='__main__':
    from rpclib.util.wsgi_wrapper import run_twisted

    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('rpclib.protocol.xml').setLevel(logging.DEBUG)
    logging.getLogger('twisted').setLevel(logging.DEBUG)

    application = Application([UserService],
        tns='rpclib.examples.authentication',
        interface=Wsdl11(),
        in_protocol=Soap11(validator='lxml'),
        out_protocol=Soap11()
    )

    twisted_apps = [
        (WsgiApplication(application), 'app'),
    ]

    sys.exit(run_twisted(twisted_apps, 7789))
Example #20
0
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
#

import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('rpclib.protocol.xml')
logger.setLevel(logging.DEBUG)

from rpclib.application import Application
from rpclib.test.interop.server._service import services
from rpclib.protocol.soap import Soap11
from rpclib.protocol.http import HttpRpc
from rpclib.interface.wsdl import Wsdl11

httprpc_soap_application = Application(services,
    'rpclib.test.interop.server.httprpc.soap', Wsdl11(), HttpRpc(), Soap11())

from rpclib.server.wsgi import WsgiApplication

if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
        from wsgiref.validate import validator

        wsgi_application = WsgiApplication(httprpc_soap_application)
        server = make_server('0.0.0.0', 9756, validator(wsgi_application))

        logger.info('Starting interop server at %s:%s.' % ('0.0.0.0', 9756))
        logger.info('WSDL is at: /?wsdl')
        server.serve_forever()
Example #21
0
        @param name the name to say hello to
        @param the number of times to say hello
        @return the completed array
        '''

        for i in range(times):
            yield 'Hello, %s' % name


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print("Error: example server code requires Python >= 2.5")

    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('rpclib.protocol.xml').setLevel(logging.DEBUG)

    application = Application([HelloWorldService],
                              'rpclib.examples.hello.http',
                              interface=Wsdl11(),
                              in_protocol=HttpRpc(),
                              out_protocol=XmlObject())

    server = make_server('127.0.0.1', 7789, WsgiApplication(application))

    print("listening to http://127.0.0.1:7789")
    print("wsdl is at: http://localhost:7789/?wsdl")

    server.serve_forever()
Example #22
0
 def setUp(self):
     self.app = Application([MultipleReturnService], 'tns', Wsdl11(),
                            Soap11(), Soap11())
     self.app.interface.build_interface_document('url')
Example #23
0
            freebusy = []
            for fb_request in fb_requests:
                calendar_folder = fb_request["folder"]
                if calendar_folder is None:
                    log.warn("no calendar folder found for '%s'" % user_email)
                    fb_response \
                        = ExchangeService._freebusy_lookup_error_response()
                else:
                    fb_response \
                        = ExchangeService._freebusy_response(calendar_folder,
                                                             timezone,
                                                             freebusy_view_options)
                freebusy.append(fb_response)
        else:
            freebusy = None

        if suggestions_view_options is not None:
            suggestions \
                = ExchangeService._suggestions_response(timezone,
                                                        suggestions_view_options)
        else:
            suggestions = None
        
        return (freebusy, suggestions)

EwsApp = Application([ExchangeService], EWS_M_NS,
                     name="ExchangeApplication",
                     interface=Wsdl11(), in_protocol=Soap11(), out_protocol=Soap11())

AsController = WsgiApplication(EwsApp)
Example #24
0
def build_app(service_list, tns, name):
    app = Application(service_list, tns, Wsdl11(), Soap11(), Soap11(), name=name)
    app.transport = "http://schemas.xmlsoap.org/soap/http"
    return app
Example #25
0
File: async.py Project: rch/rpclib
            time.sleep(seconds)

            client = make_service_client(replyto, self)
            client.woke_up('good morning', msgid=msgid)

        Thread(target=run).start()

    @srpc(String, _is_callback=True)
    def woke_up(message):
        pass


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print("Error: example server code requires Python >= 2.5")

    application = Application([SleepingService],
                              'rpclib.examples.async',
                              interface=Wsdl11(),
                              in_protocol=Soap11(),
                              out_protocol=Soap11())

    server = make_server('127.0.0.1', 7789, WsgiApplication(application))

    print("listening to http://127.0.0.1:7789")
    print("wsdl is at: http://localhost:7789/?wsdl")

    server.serve_forever()
Example #26
0
    def delete_user(userid):
        global user_database

        del user_database[userid]

    @srpc(_returns=Array(User))
    def list_users():
        global user_database

        return user_database.values()


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print("Error: example server code requires Python >= 2.5")

    application = Application([UserManager],
                              'rpclib.examples.complex',
                              interface=Wsdl11(),
                              in_protocol=Soap11(),
                              out_protocol=Soap11())

    server = make_server('127.0.0.1', 7789, WsgiApplication(application))

    print("listening to http://127.0.0.1:7789")
    print("wsdl is at: http://localhost:7789/?wsdl")

    server.serve_forever()
Example #27
0
    def test_rpc(self):
        import sqlalchemy
        from sqlalchemy import sql

        class KeyValuePair(TableSerializer, self.DeclarativeBase):
            __tablename__ = 'key_value_store'
            __namespace__ = 'punk'

            key = Column(sqlalchemy.String(100), nullable=False, primary_key=True)
            value = Column(sqlalchemy.String, nullable=False)

        self.metadata.create_all(self.engine)

        import hashlib

        session = self.Session()

        for i in range(1, 10):
            key = str(i)
            m = hashlib.md5()
            m.update(key)
            value = m.hexdigest()

            session.add(KeyValuePair(key=key, value=value))

        session.commit()

        from rpclib.service import ServiceBase
        from rpclib.model.complex import Array
        from rpclib.model.primitive import String

        class Service(ServiceBase):
            @rpc(String(max_occurs='unbounded'),
                    _returns=Array(KeyValuePair),
                    _in_variable_names={
                        'keys': 'key'
                    }
                )
            def get_values(ctx, keys):
                session = self.Session()

                return session.query(KeyValuePair).filter(sql.and_(
                    KeyValuePair.key.in_(keys)
                )).order_by(KeyValuePair.key)

        application = Application([Service],
            interface=Wsdl11(),
            in_protocol=HttpRpc(),
            out_protocol=Soap11(),
            name='Service', tns='tns'
        )

        from rpclib.server.wsgi import WsgiMethodContext

        ctx = WsgiMethodContext(application, {
            'QUERY_STRING': 'key=1&key=2&key=3',
            'PATH_INFO': '/get_values',
        }, 'some-content-type')

        from rpclib.server import ServerBase

        server = ServerBase(application)
        server.get_in_object(ctx)
        server.get_out_object(ctx)
        server.get_out_string(ctx)

        i = 0
        for e in ctx.out_document[0][0][0]:
            i+=1
            key = str(i)
            m = hashlib.md5()
            m.update(key)
            value = m.hexdigest()

            _key = e.find('{%s}key' % KeyValuePair.get_namespace())
            _value = e.find('{%s}value' % KeyValuePair.get_namespace())

            print((_key, _key.text))
            print((_value, _value.text))

            self.assertEquals(_key.text, key)
            self.assertEquals(_value.text, value)
Example #28
0
        @param name the name to say hello to
        @param the number of times to say hello
        @return the completed array
        '''

        for i in xrange(times):
            yield 'Hello, %s' % name


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print "Error: example server code requires Python >= 2.5"

    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('rpclib.protocol.xml').setLevel(logging.DEBUG)

    application = Application([HelloWorldService],
                              'rpclib.examples.hello.soap',
                              interface=Wsdl11(),
                              in_protocol=Soap11(),
                              out_protocol=Soap11())

    server = make_server('127.0.0.1', 7789, WsgiApplication(application))

    print "listening to http://127.0.0.1:7789"
    print "wsdl is at: http://localhost:7789/?wsdl"

    server.serve_forever()
Example #29
0
            raise Fault("Client.FileName", "File '%s' not found" % file_path)

        document = open(file_path, 'rb').read()

        # the service automatically loads the data from the file.
        # alternatively, The data could be manually loaded into memory
        # and loaded into the Attachment like:
        #   document = Attachment(data=data_from_file)
        return [document]


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print("Error: example server code requires Python >= 2.5")

    application = Application([DocumentArchiver],
                              'rpclib.examples.binary',
                              interface=Wsdl11(),
                              in_protocol=HttpRpc(),
                              out_protocol=HttpRpc())

    logging.basicConfig(level=logging.DEBUG)

    server = make_server('127.0.0.1', 7789, WsgiApplication(application))
    print("listening to http://127.0.0.1:7789")
    print("wsdl is at: http://localhost:7789/?wsdl")

    server.serve_forever()
Example #30
0
        self.session.close()


def _on_method_call(ctx):
    ctx.udc = UserDefinedContext()


def _on_method_return_object(ctx):
    # we don't do this in UserDefinedContext.__del__ simply to be able to alert
    # the client in case the commit fails.
    ctx.udc.session.commit()


application = Application([UserManagerService],
                          'rpclib.examples.user_manager',
                          interface=Wsdl11(),
                          in_protocol=Soap11(),
                          out_protocol=Soap11())

application.event_manager.add_listener('method_call', _on_method_call)
application.event_manager.add_listener('method_return_object',
                                       _on_method_return_object)

if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print "Error: example server code requires Python >= 2.5"

    wsgi_app = WsgiApplication(application)
    server = make_server('127.0.0.1', 7789, wsgi_app)
Example #31
0
    def send_location(clientid):
        print "Asking the RMI Server about ", clientid
        push_property = Pyro4.Proxy("PYRONAME:property.id")
        a = push_property.scanProplist(clientid)
        yield str(a)


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print "Error: server requires Python >= 2.5"

    logging.basicConfig(level=logging.INFO)
    logging.getLogger('rpclib.protocol.xml').setLevel(logging.DEBUG)

    application = Application([MessageService],
                              'org.temporary.soap',
                              interface=Wsdl11(),
                              in_protocol=Soap11(),
                              out_protocol=Soap11())

    port = int(os.environ.get('PORT', 5007))

    server = make_server('0.0.0.0', port, WsgiApplication(application))

    print "listening to http://0.0.0.0:%s" % port
    print "wsdl is at: http://0.0.0.0:%s/?wsdl" % port

    server.serve_forever()
Example #32
0
          _returns=String,
          _in_variable_names={
              '_to': 'to',
              '_from': 'from',
              '_message': 'message'
          },
          _out_variable_name='return')
    def send_email(_to, _from, _message):
        # do email sending here
        return repr((_to, _from, _message, 'sent!'))


if __name__ == '__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print("Error: example server code requires Python >= 2.5")

    application = Application([EmailManager],
                              'rpclib.examples.events',
                              interface=Wsdl11(),
                              in_protocol=Soap11(),
                              out_protocol=Soap11())

    server = make_server('127.0.0.1', 7789, WsgiApplication(application))

    print("listening to http://127.0.0.1:7789")
    print("wsdl is at: http://localhost:7789/?wsdl")

    server.serve_forever()