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


Python SoapDispatcher.register_function方法代码示例

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


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

示例1: test_multi_ns

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [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: run

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
 def run(self):
     dispatcher = SoapDispatcher('op_adapter_soap_disp', location = self.address, action = self.address,
             namespace = "http://smartylab.co.kr/products/op/adapter", prefix="tns", trace = True, ns = True)
     dispatcher.register_function('adapt', self.adapt, returns={'out': str},
             args={'nodeID': str, 'resourceName': str, 'duration': str, 'options': str})
     print("Starting a SOAP server for adapter layer of OP...")
     httpd = HTTPServer(("", 8008), SOAPHandler)
     httpd.dispatcher = dispatcher
     httpd.serve_forever()
开发者ID:dykim723,项目名称:robot-yujin,代码行数:11,代码来源:server.py

示例3: init_sopadispatcher

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
def init_sopadispatcher(config):
    action = "http://localhost:{0}/sonostube".format(config.port)

    logging.debug("setting soap action to: {0}".format(action))
    logging.debug("creating soap dispatcher and registering methods...")

    dispatcher = SoapDispatcher(
        'smapi_dispatcher',
        action=action,
        namespace="http://www.sonos.com/Services/1.1",
        prefix="ns",
        trace=True,
        pretty=True,
        ns=True)

    smapi = SonosMusicApi(config)

    dispatcher.register_function("getMediaURI", smapi.getmediauri,
                                 returns={"getMediaURIResult": str},
                                 args={"id": str})

    dispatcher.register_function("getLastUpdate", smapi.getlastupdate,
                                 returns={"getLastUpdateResult": {"catalog": str, "favorites": str}},
                                 args={})

    dispatcher.register_function("getMetadata", smapi.getmetadata,
                                 returns={"getMetadataResult": [{"index": int, "count": int, "total": int},
                                                                {"mediaCollection": {"id": str, "itemType": str,
                                                                                     "title": str, "canCache": str}},
                                                                {"mediaMetadata": {"id": str, "itemType": str,
                                                                                   "mimeType": str, "title": str,
                                                                                   "trackMetadata": {"artist": str,
                                                                                                     "album": str,
                                                                                                     "genre": str,
                                                                                                     "duration": int,
                                                                                                     "albumArtURI": str,
                                                                                                     "canPlay": str,
                                                                                                     "canSkip": str,
                                                                                                     "canAddToFavorites": str}}}]},
                                 args={"id": str, "index": int, "count": int})

    dispatcher.register_function("getMediaMetadata", smapi.getmediametadata,
                                 returns={"getMediaMetadataResult": [
                                     {"id": str, "itemType": str, "mimeType": str, "title": str,
                                      "trackMetadata": {"artist": str, "album": str, "genre": str, "duration": int,
                                                        "albumArtURI": str, "canPlay": str, "canSkip": str,
                                                        "canAddToFavorites": str}}]},
                                 args={"id": str})

    dispatcher.register_function("search", smapi.search,
                                 returns={"searchResult": [{"index": int, "count": int, "total": int},
                                                           {"mediaCollection": {"id": str, "itemType": str,
                                                                                "title": str, "canPlay": str,
                                                                                "canCache": str}}]},
                                 args={"id": str, "term": str, "index": int, "count": int})

    return WSGISOAPHandler(dispatcher)
开发者ID:chaocharleswang,项目名称:Sonostube,代码行数:59,代码来源:soaphandler.py

示例4: soap

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [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

示例5: TestSoapDispatcher

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [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

示例6: main

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
def main():
    dispatcher = SoapDispatcher(
        'my_dispatcher',
        location='http://'+host+':8888/',
        action='http://'+host+'8888/',
        namespace='http://security.com/security_sort.wsdl', prefix='ns0',trace=True,ns=True)
    dispatcher.register_function('Security', show_security, returns={'resp': unicode}, args={'datas': security()})
    handler = WSGISOAPHandler(dispatcher)
    wsgi_app = tornado.wsgi.WSGIContainer(handler)
    tornado_app = tornado.web.Application([('.*', tornado.web.FallbackHandler, dict(fallback=wsgi_app)),])
    server = tornado.httpserver.HTTPServer(tornado_app)
    server.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:Secure-Shell-Sister,项目名称:SOAP,代码行数:15,代码来源:server.py

示例7: test_single_ns

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [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

示例8: init_service

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
def init_service(port, servicename, userfunction, args, returns):
    # define service
    dispatcher = SoapDispatcher(
        servicename,
        location="http://localhost:%d/" % (port,),
        action="http://localhost:%d/" % (port,),  # SOAPAction
        namespace="http://example.com/%s.wsdl" % (servicename,),
        prefix="ns0",
        trace=True,
        ns=True,
    )

    # register the user function
    dispatcher.register_function(servicename, userfunction, returns=returns, args=args)

    # start service
    print("Starting server '%s' on port %i ..." % (servicename, port))
    httpd = HTTPServer(("", port), SOAPHandler)
    httpd.dispatcher = dispatcher
    httpd.serve_forever()
开发者ID:dcherix,项目名称:apiontology-demonstrator,代码行数:22,代码来源:service.py

示例9: get_wsapplication

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
def get_wsapplication():
    dispatcher = SoapDispatcher(
        'thunder_counter_dispatcher',
        location = str(gConfig['webservice']['location']),
        action = str(gConfig['webservice']['action']),
        namespace = str(gConfig['webservice']['namespace']), 
        prefix = str(gConfig['webservice']['prefix']),
        trace = True,
        ns = True)
    dispatcher.register_function('login', 
                                 webservice_login,
                                 returns={'Result': str}, 
                                 args={'username': str, 'password': str})    
    dispatcher.register_function('GetFlashofDate', 
                                 webservice_GetFlashofDate,
                                 returns={'Result': str}, 
                                 args={'in0': str, 'in1': str})    
    dispatcher.register_function('GetFlashofEnvelope', 
                                 webservice_GetFlashofEnvelope,
                                 returns={'Result': str}, 
                                 args={'in0': str, 'in1': str, 'in2': str,'in3': str, 'in4': str, 'in5': str})    
    wsapplication = WSGISOAPHandler(dispatcher)
    return wsapplication
开发者ID:kamijawa,项目名称:ogc_server,代码行数:25,代码来源:soap_server.py

示例10: len

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
    for _ in itertools.repeat(None, len(result_matrix)):
        index, res = receiveResult()
        result_matrix[index] = res

    print "%s seconds" % (time.time() - start_time)

    return {'result_matrix': result_matrix, 'result_matrix_width': second_matrix_width,
        'result_matrix_height': first_matrix_height}

dispatcher = SoapDispatcher(
    'multiplyMatrix',
    location = "http://localhost:%d/" % SERVER_PORT,
    action   = "http://localhost:%d/" % SERVER_PORT,
    trace    = True,
    ns       = True
)

dispatcher.register_function(
    'multiplyMatrix',
    multiplyMatrix,
    returns = { 'result_matrix': [int], 'result_matrix_width': int, 'result_matrix_height': int },
    args    = { 'first_matrix':  [int], 'first_matrix_width':  int, 'first_matrix_height':  int,
                'second_matrix': [int], 'second_matrix_width': int, 'second_matrix_height': int }
)

httpd = HTTPServer(("", SERVER_PORT), SOAPHandler)
httpd.dispatcher = dispatcher

httpd.serve_forever()
开发者ID:ivan1993spb,项目名称:py_mpi_matrix_mult,代码行数:31,代码来源:mult_matrix_server.py

示例11: SoapDispatcher

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
from pysimplesoap.server import SoapDispatcher, SOAPHandler
from BaseHTTPServer import HTTPServer
from operations import create, read, update, delete

dispatcher = SoapDispatcher(
    'my_dispatcher',
    location="http://localhost:8008/",
    action='http://localhost:8008/',  # SOAPAction
    namespace="http://example.com/sample.wsdl", prefix="ns0",
    trace=True,
    ns=True)

# register the user functions
dispatcher.register_function('Create', create,
    returns={'Node': str},
    args={'doc_name': str, 'doc_content': str})

dispatcher.register_function('Read', read,
    returns={'Node': str},
    args={'doc_name': str})

dispatcher.register_function('Update', update,
    returns={'Node': str},
    args={'doc_name': str, 'doc_content': str})

dispatcher.register_function('Delete', delete,
    returns={'Node': str},
    args={'doc_name': str})

print "Starting server at 8008..."
开发者ID:kn1m,项目名称:Lab3-AK,代码行数:32,代码来源:core.py

示例12: on

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
namespace = "http://example.com/sample.wsdl", prefix="ns0",
trace = True,
ns = True)

def on():
    return "on"
def off():
    return "off"

def status():
    return "1024"

# register the user function

dispatcher.register_function('on', on,
    args={},
    returns={'result': str} 
    )

dispatcher.register_function('off', off,
    args={},
    returns={'result': str} 
    )

dispatcher.register_function('status', status,
    args={},
    returns={'humidity': str} 
    )

logging.info("Starting server...")
httpd = HTTPServer(("", 8050),SOAPHandler)
httpd.dispatcher = dispatcher
开发者ID:Kondziowy,项目名称:rpi-api-examples,代码行数:34,代码来源:http_server_soap.py

示例13: _start_soap_server

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
    def _start_soap_server(self):
        """
        To launch a SOAP server for the adapter
        :return:
        """
        dispatcher = SoapDispatcher('concert_adapter_soap_server', location = SOAP_SERVER_ADDRESS, action = SOAP_SERVER_ADDRESS,
                namespace = "http://smartylab.co.kr/products/op/adapter", prefix="tns", ns = True)

        # To register a method for LinkGraph Service Invocation
        dispatcher.register_function('invoke_adapter', self.receive_service_invocation, returns={'out': str},
            args={
                'LinkGraph': {
                    'name': str,
                    'nodes': [{
                        'Node': {
                            'id': str,
                            'uri': str,
                            'min': int,
                            'max': int,
                            'parameters': [{
                                'parameter': {
                                    'message': str,
                                    'frequency': int
                                }
                            }]
                        }
                    }],
                    'topics': [{
                        'Topic': {
                            'id': str,
                            'type': str
                        }
                    }],
                    'actions': [{
                        'Action': {
                            'id': str,           # action id
                            'type': str,         # action specification
                            'goal_type': str     # goal message type
                        }
                    }],
                    'services': [{
                        'Service': {
                            'id': str,          # service id
                            'type': str,        # service class
                            'persistency': str  # persistency
                        }
                    }],
                    'edges': [{
                        'Edge': {
                            'start': str,
                            'finish': str,
                            'remap_from': str,
                            'remap_to': str
                        }
                    }],
                    'methods': [{
                        'Method': {
                            'address': str,
                            'namespace': str,
                            'name': str,
                            'return_name': str,
                            'param': str
                        }
                    }]
                }
            }
        )

        # To register a method for Single Node Service Invocation
        dispatcher.register_function('send_topic_msg', self._send_topic_msg, returns={'out': str},
            args={
                'namespace': str,
                'message_val': str
            }
        )

        # To register a method for sending Action messages
        dispatcher.register_function('send_action_msg', self._send_action_msg, returns={'out': str},
            args={
                'namespace': str,
                'message_val': str
            }
        )


        # To register a method for sending Service messages
        dispatcher.register_function('send_service_msg', self._send_service_msg, returns={'out': str},
            args={
                'namespace': str,
                'message_val': str
            }
        )


        # To register a method for Releasing Allocated Resources
        dispatcher.register_function('release_allocated_resources', self.release_allocated_resources, returns={'out': bool}, args={})

        # To create SOAP Server
        rospy.loginfo("Starting a SOAP server...")
        self.httpd = HTTPServer(("", int(SOAP_SERVER_PORT)), SOAPHandler)
#.........这里部分代码省略.........
开发者ID:smartylab,项目名称:concert_adapter,代码行数:103,代码来源:adapter_old.py

示例14: str

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
    if number == 9:
        username =  getpass.getuser()
        return str(username)

    # Last value
    return None

# ---------------------------------------------------------

# do not change anything unless you know what you're doing.
port=8008
dispatcher = SoapDispatcher(
    'my_dispatcher',
    location = "http://localhost:8008/",
    action = 'http://localhost:8008/', # SOAPAction
    namespace = "http://example.com/sample.wsdl", prefix="ns0",
    trace = True,
    ns = True)

# do not change anything unless you know what you're doing.
dispatcher.register_function('get_value', get_value,
    returns={'resultaat': str},   # return data type
    args={'number': int}         # it seems that an argument is mandatory, although not needed as input for this function: therefore a dummy argument is supplied but not used.
    )

# Let this agent listen forever, do not change anything unless needed.
print "Starting server on port",port,"..."
httpd = HTTPServer(("", port), SOAPHandler)
httpd.dispatcher = dispatcher
httpd.serve_forever()
开发者ID:boevering,项目名称:HogeschoolUtrecht,代码行数:32,代码来源:agent.py

示例15: SoapDispatcher

# 需要导入模块: from pysimplesoap.server import SoapDispatcher [as 别名]
# 或者: from pysimplesoap.server.SoapDispatcher import register_function [as 别名]
                current_path = current_path + '/'
            return True
        return False


dispatcher = SoapDispatcher(
    'my_dispatcher', 
    location='http://localhost:8008/', 
    action='http://localhost:8008/', 
    namespace='http://example.com/sample.wsdl', 
    prefix='ns0', 
    trace=True, 
    ns=True)

dispatcher.register_function('rm', rm, 
    returns={'Result': bool}, 
    args={'filename': str})

dispatcher.register_function('cp', cp, 
    returns={'Result': bool}, 
    args={'src': str, 'dest': str})

dispatcher.register_function('rename', rename, 
    returns={'Result': bool}, 
    args={'src': str, 'dest': str})

dispatcher.register_function('ls_dir', ls_dir, 
    returns={'Result': list}, 
    args={'path': str})

dispatcher.register_function('ls_file', ls_file, 
开发者ID:lavenresearch,项目名称:cloudStorageService,代码行数:33,代码来源:server.py


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