def __init__(self, interface): if spyne.interface.HAS_WSDL: from spyne.interface.wsdl import Wsdl11 self.wsdl11 = Wsdl11(interface) else: self.wsdl11 = None
def __init__(self, interface, wsdl11=None): self.wsdl11 = wsdl11 if self.wsdl11 is None and spyne.interface.HAS_WSDL: from spyne.interface.wsdl import Wsdl11 self.wsdl11 = Wsdl11(interface)
def setUp(self): self.app = Application([MultipleReturnService], 'tns', in_protocol=Soap11(), out_protocol=Soap11()) self.app.transport = 'none' self.wsdl = Wsdl11(self.app.interface) self.wsdl.build_interface_document('URL')
#!/usr/bin/env python from lxml import etree from spyne.test.sort_wsdl import sort_wsdl from spyne.interface.wsdl import Wsdl11 from spyne.test.interop.server._service import services from spyne.application import Application app = Application(services, 'spyne.test.interop.server') app.transport = 'http://schemas.xmlsoap.org/soap/http' wsdl = Wsdl11(app.interface) wsdl.build_interface_document('http://localhost:9754/') elt = etree.ElementTree(etree.fromstring(wsdl.get_interface_document())) sort_wsdl(elt) s = etree.tostring(elt) # minidom's serialization seems to put attributes in alphabetic order. # this is exactly what we want here. from xml.dom.minidom import parseString doc = parseString(s) s = doc.toprettyxml(indent=' ', newl='\n', encoding='utf8') s = s.replace(" xmlns:","\n xmlns:") open('wsdl.xml', 'w').write(s) print 'wsdl.xml written'
def save_order_to_database(user_id, food_id, amount): if amount >= 10: return False return True class OrderFoodService(ServiceBase): @rpc(Mandatory.Integer, Mandatory.Integer, Mandatory.Integer, _returns=Mandatory.String) def order_food(ctx, user_id, food_id, amount): result = save_order_to_database(user_id, food_id, amount) if result: return 'ok' else: return "We don't have enough supplies to fulfill your order. Sorry" order_food_service = csrf_exempt( DjangoApplication( Application( [OrderFoodService], 'webdbhazi.services.order', in_protocol=Soap11(), out_protocol=Soap11(), interface=Wsdl11(), )))
def run(): time.sleep(seconds) client = make_service_client(replyto, self) client.woke_up('good morning', msgid=msgid) Thread(target=run).start() @srpc(String, _is_callback=True) def woke_up(message): pass if __name__=='__main__': logging.basicConfig(level=logging.DEBUG) logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG) try: from wsgiref.simple_server import make_server except ImportError: logger.error("Error: example server code requires Python >= 2.5") application = Application([SleepingService], 'spyne.examples.async', interface=Wsdl11(), in_protocol=Soap11(), out_protocol=Soap11()) server = make_server('127.0.0.1', 7789, WsgiApplication(application)) logging.info("listening to http://127.0.0.1:7789") logging.info("wsdl is at: http://localhost:7789/?wsdl") server.serve_forever()