當前位置: 首頁>>代碼示例>>Python>>正文


Python server.SoapDispatcher類代碼示例

本文整理匯總了Python中pysimplesoap.server.SoapDispatcher的典型用法代碼示例。如果您正苦於以下問題:Python SoapDispatcher類的具體用法?Python SoapDispatcher怎麽用?Python SoapDispatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SoapDispatcher類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

 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,代碼行數:9,代碼來源:server.py

示例2: soap

 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,代碼行數:54,代碼來源:views.py

示例3: main

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,代碼行數:13,代碼來源:server.py

示例4: test_multi_ns

 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,代碼行數:26,代碼來源:server_multins_test.py

示例5: test_single_ns

 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,代碼行數:20,代碼來源:server_multins_test.py

示例6: init_service

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,代碼行數:20,代碼來源:service.py

示例7: TestSoapDispatcher

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,代碼行數:52,代碼來源:soapdispatcher_test2.py

示例8: setUp

    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'
                                    )
開發者ID:n1k9,項目名稱:pysimplesoap,代碼行數:19,代碼來源:soapdispatcher_test2.py

示例9: setUp

    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)
開發者ID:JAVTAMVI,項目名稱:pysimplesoap,代碼行數:19,代碼來源:soapdispatcher_test.py

示例10: get_wsapplication

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,代碼行數:23,代碼來源:soap_server.py

示例11: print

		#print(xmlElm.children())
		#img = xmlElm.unmarshall({'img':array.array})
		print(img)
		with open("out\\" + name, 'wb') as f2:
			img.tofile(f2)
	except Exception as e:
		print e
	return 0

# If the program is run directly or passed as an argument to the python
# interpreter then create a server instance and show window
if __name__ == "__main__":
	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 function
	dispatcher.register_function('uploadImages', uploadImages, 
		returns={'Result': int},
			args={'imgs_str': str})

	dispatcher.register_function('uploadImage', uploadImage, 
		returns={'Result': int},
			args={'name': str, 'imgstr': str})

	dispatcher.register_function('uploadConfigAndImages', uploadConfigAndImages, 
		returns={'Result': int},
開發者ID:stndstn,項目名稱:minidsgn,代碼行數:31,代碼來源:uploadfilessv.py

示例12: _start_soap_server

    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,代碼行數:101,代碼來源:adapter_old.py

示例13: len

    result_matrix = [0] * (first_matrix_height*second_matrix_width)

    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
開發者ID:ivan1993spb,項目名稱:py_mpi_matrix_mult,代碼行數:29,代碼來源:mult_matrix_server.py

示例14: SoapDispatcher

    else:
        if current_path[-1] != '/':
            current_path = current_path + '/'
        cur_path = current_path + path
        if os.path.isdir(cur_path):
            current_path = cur_path
            if current_path[-1] != '/':
                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})
開發者ID:lavenresearch,項目名稱:cloudStorageService,代碼行數:32,代碼來源:server.py

示例15: SoapDispatcher

from pysimplesoap.server import SoapDispatcher, SOAPHandler, WSGISOAPHandler
import logging
import const
from BaseHTTPServer import HTTPServer
dispatcher = SoapDispatcher(
'TransServer',
location = "http://%s:8050/" % const.TARGET_IP,
action = 'http://%s:8050/' % const.TARGET_IP, # SOAPAction
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} 
    )
開發者ID:Kondziowy,項目名稱:rpi-api-examples,代碼行數:31,代碼來源:http_server_soap.py


注:本文中的pysimplesoap.server.SoapDispatcher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。