Esempio n. 1
0
    def setUpClass(cls):
        _, _, _, _, services = parse(os.path.abspath('tst/data/ne3s.wsdl'))
        service_name = 'NE3SOperationNotificationService'
        service = services[service_name]
        cls.response = {
            'managerRegistrationId': 'mgr',
            'managerRegistrationKey': 'ODYzNTQ0NTg0'
        }

        def handle_operation(**kwargs):
            return cls.response

        cls.dispatcher = SoapDispatcher(
            name='ut',
            location=
            'http://localhost:54321/services/NE3SOperationNotificationService',
            action='http://www.nokiasiemens.com/ne3s/1.0/',
            namespace='http://www.nokiasiemens.com/ne3s/1.0/',
            # namespaces={'ns': 'http://www.nokiasiemens.com/ne3s/1.0/',
            # 'soapenv': 'http://schemas.xmlsoap.org/soap/envelope/'},
            documentation='NetAct simulator SOAP service',
            prefix='ns',
            debug=True)
        for port_name, port in service['ports'].iteritems():
            for operation_name, operation in port['operations'].iteritems():
                cls.dispatcher.register_function(
                    operation_name,
                    handle_operation,
                    returns=operation['output'].values()[0],
                    args=operation['input'].values()[0])
Esempio n. 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(("", int(PORT_NUMBER)), SOAPHandler)
        httpd.dispatcher = dispatcher

        print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME,
                                                         PORT_NUMBER)
        httpd.serve_forever()
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)
Esempio n. 5
0
	def run(self):
		address_port = self._address + ':{}/'.format(self._port)

		self._dispatcher = SoapDispatcher(
			name = 'GameCreator',
			location = address_port,
			action = address_port,
			namespace ='lost-world.dk',
			prefix = 'ns0',
			documentation = 'hm',
			trace = True,
			debug = True,
			ns = True,
		)

		self._dispatcher.register_function(
			'create_game',
			self.create_game,
			returns = {'ids': str},
			args = {'game_id': str, 'amount_players': int},
		)

		print("Starting SOAP server...")
		with HTTPServer((self._address, self._port), SOAPHandler) as http_server:
			http_server.dispatcher = self._dispatcher
			http_server.serve_forever()
Esempio n. 6
0
 def __init__(self):
     log.debug ("R4DSoapService.__init__")
     self.__dispatcher = SoapDispatcher (
         'r4d',
         location = "http://localhost:8008/",
         action = 'http://localhost:8008/',
         namespace = "http://ci-rt.linutronix.de/r4d.wsdl",
         prefix="r4d",
         pretty = True,
         debug = log.level is logging.DEBUG)
Esempio n. 7
0
def server_accepting_soap_requests():
    dispatcher = SoapDispatcher(
        name="WeatherServer",
        location="https://soapservice.christiansretsimpletestserver.xyz",
        action='',  # SOAPAction
        namespace="https://soapservice.christiansretsimpletestserver.xyz",
        prefix="ns0",
        trace=True,
        ns=True)
    dispatcher.register_function('CityWeatherReport',
                                 cityweatherreport,
                                 returns={'weather_report': str},
                                 args={'city_name': str})
    print('starting server')
    httpd = HTTPServer(("", 8050), SOAPHandler)
    httpd.dispatcher = dispatcher
    httpd.serve_forever()
Esempio n. 8
0
class SoapView(View):
    SOAP = SoapDispatcher(name="test",
                          action="http://127.0.0.1:8000/soap/",
                          location="http://127.0.0.1:8000/soap/",
                          namespace="namespace",
                          soap_ns="xs",
                          prefix="pys")
    NAME = None
    RESAULT = None
    NS = None
    ARG = None
    URL_KW = {}

    def dispatch(self, *args, **kwargs):
        # pdb.set_trace()
        request = args[0]
        location = request.META.get("HTTP_SOAPACTION", None)
        if self.NAME:
            self.SOAP.name = self.NAME
        if self.NS:
            self.SOAP.soap_ns = self.NS
        for k, v in kwargs.items():
            self.URL_KW[k] = v
        if location:
            self.SOAP.action = location
            self.SOAP.location = location

        self.SOAP.register_function("test",
                                    self.soap,
                                    self.RESAULT,
                                    args=self.ARG)
        return super(SoapView, self).dispatch(*args, **kwargs)

    def get(self, request, *args, **kwargs):
        return HttpResponse(self.SOAP.wsdl(), content_type="text/xml")

    def post(self, request, *a, **kw):
        xml = self.SOAP.dispatch(request.body, fault={})
        return HttpResponse(xml, content_type="text/xml")

    @abstractmethod
    def soap(self, *a, **kw):
        pass
Esempio n. 9
0
    def setUp(self):
        self.dispatcher = SoapDispatcher('Test',
                                         action='http://localhost:8008/soap',
                                         location='http://localhost:8008/soap')

        def divider(a, b):
            if b == 0:
                raise SoapFault(faultcode='DivisionByZero',
                                faultstring='Division by zero not allowed',
                                detail='test')
            return float(a) / b

        self.dispatcher.register_function('Divider',
                                          divider,
                                          returns={'DivideResult': float},
                                          args={
                                              'a': int,
                                              'b': int
                                          })
Esempio n. 10
0
    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'
                                    )
Esempio n. 11
0
    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)
Esempio n. 12
0
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()
Esempio n. 13
0
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
Esempio n. 14
0
from pysimplesoap.server import SoapDispatcher, SOAPHandler
from BaseHTTPServer import HTTPServer
from phue import Bridge
import os
import sys
import socket

dispatcher = SoapDispatcher('hue',
                            location="http://localhost:8080/",
                            namespace="http://www.sonos.com/Services/1.1",
                            trace=True,
                            debug=True)

lightActions = {
    'on': {
        'on': True
    },
    'off': {
        'on': False
    },
    'dim': {
        'on': True,
        'bri': 127
    },
    'red': {
        'on': True,
        'bri': 254,
        'hue': 0,
        'sat': 255
    },
    'green': {
Esempio n. 15
0
from pysimplesoap.server import SoapDispatcher, SOAPHandler
from BaseHTTPServer import HTTPServer


def add(a, b):
    "Add a and b"
    return a + b


dispatcher = SoapDispatcher("my_dis",
                            location='http://localhost:8000',
                            trace=True)

dispatcher.register_function('Add',
                             add,
                             returns={'res': int},
                             args={
                                 'a': int,
                                 'b': int
                             })

print "Starting"
httpd = HTTPServer(("", 8000), SOAPHandler)
httpd.dispatcher = dispatcher
httpd.serve_forever()
Esempio n. 16
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()
Esempio n. 17
0
import os
import logging
import uuid
from overcast import Overcast, utilities
from pysimplesoap.server import SoapDispatcher, SOAPHandler
from BaseHTTPServer import HTTPServer

logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('overcast-sonos')

dispatcher = SoapDispatcher('overcast-sonos',
                            location='http://localhost:8140/',
                            namespace='http://www.sonos.com/Services/1.1',
                            trace=True,
                            debug=True)

overcast = Overcast(os.environ['OVERCAST_USERNAME'],
                    os.environ['OVERCAST_PASSWORD'])

mediaCollection = {
    'id': str,
    'title': str,
    'itemType': str,
    'artistId': str,
    'artist': str,
    'albumArtURI': str,
    'canPlay': bool,
    'canEnumerate': bool,
    'canAddToFavorites': bool,
    'canScroll': bool,
    'canSkip': bool
Esempio n. 18
0
        return in0 - in1
    if in2 == '*':
        return in0 * in1
    if in2 == '/':
        return in0 / in1
    if in2 == '%':
        return in0 % in1
    return None


# criação do objeto soap
dispatcher = SoapDispatcher(
    'AbcBolinhas',
    location='http://localhost:8888/',
    action='http://localhost:8888/',
    namespace="http://localhost:8888/",
    prefix="ns0",
    documentation='Exemplo usando SOAP através de PySimpleSoap',
    trace=True,
    debug=True,
    ns=True)
# publicação do serviço, com seu alias, retorno e parâmetros
dispatcher.register_function('verifica_NumeroPar',
                             is_par,
                             returns={'out0': bool},
                             args={'in0': int})
dispatcher.register_function('verifica_CPF',
                             is_cpf,
                             returns={'out0': bool},
                             args={'in0': str})
dispatcher.register_function('verifica_Calculo',
                             calc,
Esempio n. 19
0
def get_tasks():
    print "###MESSAGE START###"

    #pass
    #print "ping: "+str(args)
    logging.warning("getTasks.")
    print "###MESSAGE END###"

    return list


dispatcher = SoapDispatcher(
    'server',
    location=
    "http://ppm-sanger-dev.dipr.partners.org:8080/gp/services/Analysis",
    action=('submitJob', 'ping', 'getTasks'),  # SOAPAction
    trace=True,
    ns=False)
'''	#namespace = "http://ppm-sanger-dev.dipr.partners.org:8080/gp/services/Analysis?wsdl",
	namespace = "http://hive49-206.dipr.partners.org:8080/gp/services/Analysis?wsdl",'''

# register submitJob
#dispatcher.register_function('submitJob', echo,
#	returns={'response': dict},
#	args={'request': dict})

# register submitJob
dispatcher.register_function('submitJob',
                             submit,
                             returns={'submitJobResponse': list},
from pysimplesoap.server import SoapDispatcher, WSGISOAPHandler

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


# これをやっても、以下のエラーが出る
# AttributeError: 'str' object has no attribute 'decode'
class WSGISOAPPython3Handler(WSGISOAPHandler):
    def do_post(self, environ, start_response):
        length = int(environ['CONTENT_LENGTH'])
        request = environ['wsgi.input'].read(length)
        response = self.dispatcher.dispatch(str(request))
        start_response('200 OK', [('Content-Type', 'text/xml'),
                                  ('Content-Length', str(len(response)))])
        return [response]


def say_hello(RequestInterface):
    return RequestInterface.userName


dispatcher.register_function(
from pysimplesoap.server import SoapDispatcher, SOAPHandler
from http.server import HTTPServer
import requests


def get_cases(request):
    case_endpoint = "http://0.0.0.0:9070/case"
    return requests.get(case_endpoint).json()


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

# register the user function
dispatcher.register_function('get_cases', get_cases, returns={'Cases': str})

print("Starting server...")
httpd = HTTPServer(("", 8008), SOAPHandler)
httpd.dispatcher = dispatcher
httpd.serve_forever()
Esempio n. 22
0
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator

from pysimplesoap.server import SoapDispatcher, SOAPHandler, WSGISOAPHandler
from django.http import HttpResponse


def func(data):
    return data


# dispatcher declaration: however you like to declare it ;)
dispatcher = SoapDispatcher(
    'my_dispatcher',
    location="http://localhost:8000/gapp/dispatcher_handler/",
    action='http://localhost:8000/gapp/dispatcher_handler/',
    namespace="http://blah.blah.org/blah/blah/local/",
    prefix="bl1",
    ns="bl2")

# register func
dispatcher.register_function('func',
                             func,
                             returns={'result': str},
                             args={'data': str})


@csrf_exempt
def dispatcher_handler(request):
    if request.method == "POST":
        response = HttpResponse(content_type="application/xml")
Esempio n. 23
0
        content = ''
    requestMId = root.getElementsByTagName(
        'requestMessageId')[0].childNodes[0].nodeValue
    requestTime = root.getElementsByTagName(
        'requestTime')[0].childNodes[0].nodeValue
    print "\n****API Response: Command is %s****" % actionTypeValue
    #print content
    #print "*****************************\n"
    return addReponseHeader(base64.encodestring(content), requestMId,
                            requestTime, actionTypeValue)


dispatcher = SoapDispatcher(
    'PlatformService',
    location="http://localhost:8000/api/PlatformService.wsdl",
    action="http://localhost:8000/api/PlatformService.wsdl",
    namespace="http://localhost:8000/api/PlatformService.wsdl",
    prefix="ns0",
    ns="bl2")

# Register function.
dispatcher.register_function('send',
                             jobDispatch,
                             returns={'sendResponse': str},
                             args={'arg0': str})


@csrf_exempt  # not using CSRF protection.
def dispatcher_handler(request):
    if request.method == "POST":  # return function result.
        response = HttpResponse(dispatcher.dispatch(request.body))
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} 
    )
Esempio n. 25
0
                    inputDataList.get('inputData')[0].get('values').get(
                        'value')),
                'n:currencyCode':
                'EUR',
                'n:costType':
                'Base'
            }]
        }
    }


cost_shipment_service = SoapDispatcher(
    'ExternalRatingService',
    location='http://otm-soapy.appspot.com/cost_shipment',
    action='http://otm-soapy.appspot.com/cost_shipment',  #SOAPAction
    namespace='http://xmlns.oracle.com/apps/otm/ExternalRating',
    prefix='n',
    trace=True,
    ns=False,
    response_element='rexRateResult')

cost_shipment_service.register_function(
    'rexRateRequest',
    cost_shipment,
    returns={
        'n:costDetails': {
            'n:costDetail': [{
                'n:cost': str,
                'n:currencyCode': str,
                'n:costType': str
            }]
Esempio n. 26
0
        "-r", folder, "-d /data/uniprot_sprot", "-c"
    ])
    subprocess.call(shellCmd, shell=True)
    outFile = folder + "/out/" + list(os.listdir(folder + "/out"))[0]
    shellCmd = " ".join(
        ["./disulfxml", "-i", outFile, "-o", folder + "/sequence.xml"])
    subprocess.call(shellCmd, shell=True)
    with open(folder + "/sequence.xml") as f:
        out = f.read()
    return out


dispatcher = SoapDispatcher(
    'my_dispatcher',
    location="http://localhost:8008/",
    action='http://localhost:8008/',  # SOAPAction
    namespace="http://alex.tbl/webservice/disulfinder/disulfinder_soap.wsdl",
    prefix="di",
    trace=True,
    ns=True)

# register the user function
dispatcher.register_function('GetDsBonds',
                             getDsBonds,
                             returns={'getDisulfinderResponse': str},
                             args={'getDisulfinderRequest': str})

print "Starting server..."
httpd = HTTPServer(("", 8008), SOAPHandler)
httpd.dispatcher = dispatcher
httpd.serve_forever()
Esempio n. 27
0
        form_xml = forms[formID]
        return SimpleXMLElement(form_xml)
    else:
        return SimpleXMLElement(
            '<?xml version="1.0"?><error>There was an error \
                                     delivering your request</error>')


host_location = server_url
# the location and action values were the same in the example provided
# but perhaps they might need to be distinct at some point
host_action = host_location

dispatcher = SoapDispatcher('cadsr_soap_dispatcher',
                            location=host_location,
                            action=host_action,
                            namespace="http://nlm.nih.gov/sdc/form",
                            prefix="soap12",
                            ns="urn:ihe:iti:rfd:2007")

# register func
dispatcher.register_function('RetrieveFormRequest',
                             form_as_XML,
                             returns={
                                 'contentType': str,
                                 'responseCode': str,
                                 'form': {
                                     'instanceID': str,
                                 }
                             },
                             args={
                                 'prepopData': str,
Esempio n. 28
0
def adder(a,b):
    "Add two values"
    return a+b

def multiplier(a,b):
    "Multiply two values"
    return a*b

#######################


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

# register the user function
dispatcher.register_function('Adder', adder,
    returns={'AddResult': int}, 
    args={'a': int,'b': int},
    doc = 'Add two values...')

dispatcher.register_function('Multiplier', multiplier,
    returns={'MultResult': int}, 
    args={'a': int,'b': int},
    doc = 'Multiply two values...')
Esempio n. 29
0
    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