Пример #1
0
    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(("", int(PORT_NUMBER)), SOAPHandler)
        httpd.dispatcher = dispatcher

        print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME,
                                                         PORT_NUMBER)
        httpd.serve_forever()
Пример #2
0
 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()
Пример #3
0
    def server(self):
        dispatcher = SoapDispatcher('PutDispatcher',
                                    location="http://10.42.0.1:8008",
                                    action='http://10.42.0.1:8008', # SOAPAction
                                    namespace="http://10.42.0.1:8008/put.wsdl", prefix="ns0",
                                    trace=True,
                                    ns=True)

        # register the user function
        dispatcher.register_function('Put', self.put, returns={'PutResult': bool},
                                     args={'name': str, 'destinationFrom': str, 'destinationTo': str, 'date': str,
                                           'hotelName': str, 'stayHotel': int, 'identifier': str,
                                           'coordinationType': str, 'expires': int, 'coordinatorUrl': str,
                                           'coordinatorPort': int})

        print ("PutServer Successfully Published")
        httpd = HTTPServer(("", 8008), SOAPHandler)
        httpd.dispatcher = dispatcher
        httpd.serve_forever()
Пример #4
0
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()
Пример #5
0
           <value xsi:type="xsd:string">Hello world</value>
        </Echo>
       </soap:Body>
    </soap:Envelope>"""

        print dispatcher.dispatch(xml)

        for method, doc in dispatcher.list_methods():
            request, response, doc = dispatcher.help(method)
            ##print request
            ##print response

    if '--serve' in sys.argv:
        print "Starting server..."
        httpd = HTTPServer(("", 8008), SOAPHandler)
        httpd.dispatcher = dispatcher
        httpd.serve_forever()

    if '--consume' in sys.argv:
        from client import SoapClient
        client = SoapClient(
            location="http://localhost:8008/",
            action='http://localhost:8008/',  # SOAPAction
            namespace="http://example.com/sample.wsdl",
            soap_ns='soap',
            trace=True,
            ns=False)
        response = client.Adder(p={
            'a': 1,
            'b': 2
        },
Пример #6
0
        args={'in0': str}
    )

    dispatcher.register_function('Echo', echo)

    if '--local' in sys.argv:

        wsdl = dispatcher.wsdl()

        for method, doc in dispatcher.list_methods():
            request, response, doc = dispatcher.help(method)

    if '--serve' in sys.argv:
        log.info("Starting server...")
        httpd = HTTPServer(("", 8008), SOAPHandler)
        httpd.dispatcher = dispatcher
        httpd.serve_forever()

    if '--wsgi-serve' in sys.argv:
        log.info("Starting wsgi server...")
        from wsgiref.simple_server import make_server
        application = WSGISOAPHandler(dispatcher)
        wsgid = make_server('', 8008, application)
        wsgid.serve_forever()

    if '--consume' in sys.argv:
        from .client import SoapClient
        client = SoapClient(
            location="http://localhost:8008/",
            action='http://localhost:8008/',  # SOAPAction
            namespace="http://example.com/sample.wsdl",
Пример #7
0
	def __init__(self):
		print("!!! please switch dummy off ... !!!!!")		
		sila_namespace = "http://sila-standard.org"
		
		dispatcher = SoapDispatcher( 'LARASiLADevice',
						location = "http://localhost:8008/",
						action = 'http://localhost:8008/', # SOAPAction
						namespace = sila_namespace,
						trace = True,
						ns = True )
		
		# register the user function
		dispatcher.register_function('GetStatus', self.get_status,
									 returns={'Status': int}, 
									 args={'requestID': str} )
									 			
		dispatcher.register_function('GetDeviceIdentification', self.get_device_identification,
									 returns={'SiLA_DeviceClass': int, "DeviceName": str }, 
									 args={'requestID': str} )
									 
		dispatcher.register_function('Initialize', self.initialize,
									 returns={'Status': int}, 
									 args={'requestID': str} )
									 
		dispatcher.register_function('Reset', self.reset,
									 returns={'Status': int}, 
									 args={'requestID': str} )

		dispatcher.register_function('Abort', self.abort,
									 returns={'standardResponse': int}, 
									 args={'requestID': str} )

		dispatcher.register_function('Pause', self.pause,
									 returns={'standardResponse': int}, 
									 args={'requestID': str} )
									 
		dispatcher.register_function('DoContinue', self.doContinue,
									 returns={'Status': int}, 
									 args={'requestID': str} )

		dispatcher.register_function('LockDevice', self.lockDevice,
									 returns={'Status': int}, 
									 args={'requestID': str} )									 

		dispatcher.register_function('UnlockDevice', self.unlockDevice,
									 returns={'Status': int}, 
									 args={'requestID': str} )	
									 
		dispatcher.register_function('OpenDoor', self.openDoor,
									 returns={ }, 
									 args={'requestID': int, 'lockID': str } )

		dispatcher.register_function('CloseDoor', self.closeDoor,
									 returns={ }, 
									 args={'requestID': int, 'lockID': str } )
			
		dispatcher.register_function('ExecuteMethod', self.executeMethod,
									 returns={'complexResponse':[] }, 
									 args={'requestID': int, 'lockID': str, 'methodName':str,'priority':int  } )
		
		print "Starting sila device soap server..."
		httpd = HTTPServer(("", 8008), SOAPHandler)
		httpd.dispatcher = dispatcher
		
		# blink to show "I am ready" 
		blink(3, 0.1, SiLADevice.green_LED)
		
		httpd.serve_forever()
		GPIO.cleanup()
Пример #8
0
def test_server_run():
    print "Starting server..."
    httpd = HTTPServer(("", 8008), SOAPHandler)
    httpd.dispatcher = dispatcher
    httpd.serve_forever()