当前位置: 首页>>代码示例>>Python>>正文


Python SoapDispatcher.dispatch方法代码示例

本文整理汇总了Python中pysimplesoap.server.SoapDispatcher.dispatch方法的典型用法代码示例。如果您正苦于以下问题:Python SoapDispatcher.dispatch方法的具体用法?Python SoapDispatcher.dispatch怎么用?Python SoapDispatcher.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysimplesoap.server.SoapDispatcher的用法示例。


在下文中一共展示了SoapDispatcher.dispatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_multi_ns

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import dispatch [as 别名]
 def test_multi_ns(self):
     dispatcher = SoapDispatcher(
         name = "MTClientWS",
         location = "http://localhost:8008/ws/MTClientWS",
         action = 'http://localhost:8008/ws/MTClientWS', # SOAPAction
         namespace = "http://external.mt.moboperator", prefix="external",
         documentation = 'moboperator MTClientWS',
         namespaces = {
             'external': 'http://external.mt.moboperator', 
             'model': 'http://model.common.mt.moboperator'
         },
         ns = True,
         pretty=False,
         debug=True)
     
     dispatcher.register_function('activateSubscriptions', 
         self._multi_ns_func,
         returns=self._multi_ns_func.returns,
         args=self._multi_ns_func.args)
     dispatcher.register_function('updateDeliveryStatus',
         self._updateDeliveryStatus,
         returns=self._updateDeliveryStatus.returns,
         args=self._updateDeliveryStatus.args)
     
     self.assertEqual(dispatcher.dispatch(REQ), MULTI_NS_RESP)
     self.assertEqual(dispatcher.dispatch(REQ1), MULTI_NS_RESP1)
开发者ID:KongJustin,项目名称:pysimplesoap,代码行数:28,代码来源:server_multins_test.py

示例2: TestSoapDispatcher

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import dispatch [as 别名]
class TestSoapDispatcher(unittest.TestCase):
    def setUp(self):
        self.disp = SoapDispatcher(
            name="PySimpleSoapSample",
            location="http://localhost:8008/",
            action='http://localhost:8008/',  # SOAPAction
            namespace="http://example.com/pysimplesoapsamle/", prefix="ns0",
            documentation='Example soap service using PySimpleSoap',
            debug=True,
            ns=True)

        self.disp.register_function('dummy', dummy,
                                    returns={'out0': str},
                                    args={'in0': str}
                                    )
        self.disp.register_function('dummy_response_element', dummy,
                                    returns={'out0': str},
                                    args={'in0': str},
                                    response_element_name='diffRespElemName'
                                    )

    def test_zero(self):
        response = """<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><dummyResponse xmlns="http://example.com/pysimplesoapsamle/"><out0>Hello world</out0></dummyResponse></soap:Body></soap:Envelope>"""

        request = """\
<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <soap:Body>
         <dummy xmlns="http://example.com/sample.wsdl">
           <in0 xsi:type="xsd:string">Hello world</in0>
        </dummy>
       </soap:Body>
    </soap:Envelope>"""
        self.assertEqual(self.disp.dispatch(request), response)

    def test_response_element_name(self):
        response = """<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><diffRespElemName xmlns="http://example.com/pysimplesoapsamle/"><out0>Hello world</out0></diffRespElemName></soap:Body></soap:Envelope>"""

        request = """\
<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <soap:Body>
         <dummy_response_element xmlns="http://example.com/sample.wsdl">
           <in0 xsi:type="xsd:string">Hello world</in0>
        </dummy_response_element>
       </soap:Body>
    </soap:Envelope>"""
        self.assertEqual(self.disp.dispatch(request), response)
开发者ID:n1k9,项目名称:pysimplesoap,代码行数:54,代码来源:soapdispatcher_test2.py

示例3: soap

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import dispatch [as 别名]
 def soap(self):
     from pysimplesoap.server import SoapDispatcher
     import uliweb.contrib.soap as soap
     from uliweb.utils.common import import_attr
     from uliweb import application as app, response, url_for
     from functools import partial
     
     global __soap_dispatcher__
     
     if not __soap_dispatcher__:
         location = "%s://%s%s" % (
             request.environ['wsgi.url_scheme'],
             request.environ['HTTP_HOST'],
             request.path)
         namespace = functions.get_var(self.config).get('namespace') or location
         documentation = functions.get_var(self.config).get('documentation')
         dispatcher = SoapDispatcher(
             name = functions.get_var(self.config).get('name'),
             location = location,
             action = '', # SOAPAction
             namespace = namespace,
             prefix=functions.get_var(self.config).get('prefix'),
             documentation = documentation,
             exception_handler = partial(exception_handler, response=response),
             ns = True)
         for name, (func, returns, args, doc) in soap.__soap_functions__.get(self.config, {}).items():
             if isinstance(func, (str, unicode)):
                 func = import_attr(func)
             dispatcher.register_function(name, func, returns, args, doc)
     else:
         dispatcher = __soap_dispatcher__
         
     if 'wsdl' in request.GET:
         # Return Web Service Description
         response.headers['Content-Type'] = 'text/xml'
         response.write(dispatcher.wsdl())
         return response
     elif request.method == 'POST':
         def _call(func, args):
             rule = SimpleRule()
             rule.endpoint = func
             mod, handler_cls, handler = app.prepare_request(request, rule)
             result = app.call_view(mod, handler_cls, handler, request, response, _wrap_result, kwargs=args)
             r = _fix_soap_datatype(result)
             return r
         # Process normal Soap Operation
         response.headers['Content-Type'] = 'text/xml'
         log.debug("---request message---")
         log.debug(request.data)
         result = dispatcher.dispatch(request.data, call_function=_call)
         log.debug("---response message---")
         log.debug(result)
         response.write(result)
         return response
开发者ID:08haozi,项目名称:uliweb,代码行数:56,代码来源:views.py

示例4: test_single_ns

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import dispatch [as 别名]
 def test_single_ns(self):
     dispatcher = SoapDispatcher(
         name = "MTClientWS",
         location = "http://localhost:8008/ws/MTClientWS",
         action = 'http://localhost:8008/ws/MTClientWS', # SOAPAction
         namespace = "http://external.mt.moboperator", prefix="external",
         documentation = 'moboperator MTClientWS',
         ns = True,
         pretty=False,
         debug=True)
     
     dispatcher.register_function('activateSubscriptions', 
         self._single_ns_func,
         returns=self._single_ns_func.returns,
         args=self._single_ns_func.args)
     
     # I don't fully know if that is a valid response for a given request,
     # but I tested it, to be sure that a multi namespace function
     # doesn't brake anything.
     self.assertEqual(dispatcher.dispatch(REQ), SINGLE_NS_RESP)
开发者ID:KongJustin,项目名称:pysimplesoap,代码行数:22,代码来源:server_multins_test.py

示例5: TestSoapDispatcher

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import dispatch [as 别名]
class TestSoapDispatcher(unittest.TestCase):
    def eq(self, value, expectation, msg=None):
        if msg is not None:
            msg += ' %s' % value
            self.assertEqual(value, expectation, msg)
        else:
            self.assertEqual(value, expectation, "%s\n---\n%s" % (value, expectation))

    def setUp(self):
        self.dispatcher = SoapDispatcher(
            name="PySimpleSoapSample",
            location="http://localhost:8008/",
            action='http://localhost:8008/',  # SOAPAction
            namespace="http://example.com/pysimplesoapsamle/", prefix="ns0",
            documentation='Example soap service using PySimpleSoap',
            debug=True,
            ns=True)

        self.dispatcher.register_function('Adder', adder,
            returns={'AddResult': {'ab': int, 'dd': str}},
            args={'p': {'a': int, 'b': int}, 'dt': Date, 'c': [{'d': Decimal}]})

        self.dispatcher.register_function('Dummy', dummy,
            returns={'out0': str},
            args={'in0': str})

        self.dispatcher.register_function('Echo', echo)

    def test_classic_dialect(self):
        # adder local test (classic soap dialect)
        resp = """<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><AdderResponse xmlns="http://example.com/pysimplesoapsamle/"><dd>5000000.3</dd><ab>3</ab><dt>2011-07-24</dt></AdderResponse></soap:Body></soap:Envelope>"""
        xml = """<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body>
         <Adder xmlns="http://example.com/sample.wsdl">
           <p><a>1</a><b>2</b></p><c><d>5000000.1</d><d>.2</d></c><dt>2010-07-24</dt>
        </Adder>
       </soap:Body>
    </soap:Envelope>"""
        self.eq(self.dispatcher.dispatch(xml), resp)

    def test_modern_dialect(self):
        # adder local test (modern soap dialect, SoapUI)
        resp = """<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:pys="http://example.com/pysimplesoapsamle/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><pys:AdderResponse><dd>15.021</dd><ab>12</ab><dt>1970-07-20</dt></pys:AdderResponse></soapenv:Body></soapenv:Envelope>"""
        xml = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pys="http://example.com/pysimplesoapsamle/">
   <soapenv:Header/>
   <soapenv:Body>
      <pys:Adder>
         <pys:p><pys:a>9</pys:a><pys:b>3</pys:b></pys:p>
         <pys:dt>1969-07-20<!--1969-07-20T21:28:00--></pys:dt>
         <pys:c><pys:d>10.001</pys:d><pys:d>5.02</pys:d></pys:c>
      </pys:Adder>
   </soapenv:Body>
</soapenv:Envelope>
    """
        self.eq(self.dispatcher.dispatch(xml), resp)

    def test_echo(self):
        # echo local test (generic soap service)
        resp = """<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><EchoResponse xmlns="http://example.com/pysimplesoapsamle/"><value xsi:type="xsd:string">Hello world</value></EchoResponse></soap:Body></soap:Envelope>"""
        xml = """<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <soap:Body>
         <Echo xmlns="http://example.com/sample.wsdl">
           <value xsi:type="xsd:string">Hello world</value>
        </Echo>
       </soap:Body>
    </soap:Envelope>"""
        self.eq(self.dispatcher.dispatch(xml), resp)
开发者ID:JAVTAMVI,项目名称:pysimplesoap,代码行数:74,代码来源:soapdispatcher_test.py


注:本文中的pysimplesoap.server.SoapDispatcher.dispatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。