Ejemplo n.º 1
0
 def setUp(self):
     self.app = Application([TestService],
                            rpclib.interface.wsdl.Wsdl11,
                            rpclib.protocol.soap.Soap11,
                            tns='tns')
     self.srv = TestService()
     self._wsdl = self.app.interface.get_interface_document('')
     self.wsdl = etree.fromstring(self._wsdl)
Ejemplo n.º 2
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 DefinitionBase
        @param A class based on DefinitionBase
        '''

        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
Ejemplo n.º 3
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 DefinitionBase
        @param A class based on DefinitionBase
        '''

        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
Ejemplo n.º 4
0
    def test_wsdl(self):
        app = Application([TestService],
                          rpclib.interface.wsdl.Wsdl11,
                          rpclib.protocol.soap.Soap11,
                          tns='tns')

        wsdl = app.interface.get_interface_document('punk')
        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" % rpclib.ns_xsd)
        self.assertEquals([e.attrib['value'] for e in simple_type[0]], vals)
Ejemplo n.º 5
0
    def test_multiple_return(self):
        app = Application([MultipleReturnService],
                          rpclib.interface.wsdl.Wsdl11,
                          rpclib.protocol.soap.Soap11,
                          tns='tns')
        app.interface.get_interface_document('')
        srv = MultipleReturnService()
        message = srv.public_methods[0].out_message()

        self.assertEquals(len(message._type_info), 3)

        sent_xml = etree.Element('test')
        message.to_parent_element(('a', 'b', 'c'), srv.get_tns(), sent_xml)
        sent_xml = sent_xml[0]

        print etree.tostring(sent_xml, pretty_print=True)
        response_data = message.from_xml(sent_xml)

        self.assertEquals(len(response_data), 3)
        self.assertEqual(response_data[0], 'a')
        self.assertEqual(response_data[1], 'b')
        self.assertEqual(response_data[2], 'c')
Ejemplo n.º 6
0
        return "OK"

    @rpc(String, _returns=String, _public_name="do_something")
    def do_something_else(self, s):
        return s

    @rpc(Integer, _returns=Array(OtherClass))
    def return_other_class_array(self, num):
        for i in xrange(num):
            yield OtherClass(dt=datetime(2010, 12, 06), d=3.0, b=True)

    @rpc(_returns=Attachment)
    def return_binary_data(self):
        return Attachment(data=''.join([chr(i) for i in xrange(256)]))


services = [
    InteropPrimitive,
    InteropArray,
    InteropClass,
    InteropMisc,
    InteropServiceWithHeader,
    InteropException,
]

from rpclib import Application
from rpclib.protocol.soap import Soap11
from rpclib.interface.wsdl import Wsdl11Strict

soap_application = Application(services, Wsdl11Strict, Soap11, tns=__name__)
Ejemplo n.º 7
0
 def test_multiple_ns(self):
     svc = Application([MultipleNamespaceService],
                       rpclib.interface.wsdl.Wsdl11,
                       rpclib.protocol.soap.Soap11,
                       tns='tns')
     wsdl = svc.interface.get_interface_document("URL")
Ejemplo n.º 8
0
import logging

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

from rpclib import Application
from rpclib.test.interop.server._service import services
from rpclib.protocol.csv import OutCsv
from rpclib.protocol.http import HttpRpc
from rpclib.interface.wsdl import Wsdl11

httprpc_csv_application = Application(services,
                                      Wsdl11,
                                      HttpRpc,
                                      OutCsv,
                                      tns=__name__)
from rpclib.server import wsgi

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

        wsgi_application = wsgi.Application(httprpc_csv_application)
        server = make_server('0.0.0.0', 9755, validator(wsgi_application))

        logger.info('Starting interop server at %s:%s.' % ('0.0.0.0', 9755))
        logger.info('WSDL is at: /?wsdl')
        server.serve_forever()
Ejemplo n.º 9
0
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
#
"""pod being plain old data"""

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

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

httprpc_soap_application = Application(services, Wsdl11, HttpRpc, tns=__name__)
from rpclib.server import wsgi

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

        wsgi_application = wsgi.Application(httprpc_soap_application)
        server = make_server('0.0.0.0', 9757, 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()

    except ImportError: