def build_app(service_list, tns, name): app = Application(service_list, tns, name) app.transport = 'http://schemas.xmlsoap.org/soap/http' app.update_pref_map("Hippity", "Hippity") app.update_pref_map("Hoppity","Hoppity") app.update_pref_map("MissingRPCPortService","MissingRPCPortService") app.update_pref_map("SinglePortNS","SinglePortNS") app.update_pref_map("DoublePort","DoublePort") return app
def test_wsdl(self): app = Application([TestService], 'tns') wsdl = app.get_wsdl('punk') elt = etree.fromstring(wsdl) simple_type = elt.xpath('//xs:simpleType', namespaces=app.nsmap)[0] # Avoid printing debug output during test runs. #print etree.tostring(elt, pretty_print=True) #print simple_type self.assertEquals(simple_type.attrib['name'], 'DaysOfWeekEnum') self.assertEquals(simple_type[0].tag, "{%s}restriction" % namespaces.ns_xsd) self.assertEquals([e.attrib['value'] for e in simple_type[0]], vals)
def __get_binding_application(self, binding_service): '''Builds an instance of soaplib.Application The Application built is populated with an instance of a Service Class based on DefinitionBase @param A class based on DefinitionBase ''' binding_application = Application([binding_service], 'binding_application') # The lxml Element nsmap is being overridden to remove the unneeded # namespaces binding_application.nsmap = XSDGenerator.model_schema_nsmap binding_application.prefmap = \ dict([(b,a) for a,b in XSDGenerator.model_schema_nsmap.items()]) binding_application.call_routes = {} return binding_application
def __init__(self, services, tns): """Create Django view for given SOAP soaplib services and tns""" return super(DjangoSoapApp, self).__init__(Application(services, tns))
def consturct_soaplib_application(service_list, tns): soap_app = Application(service_list, tns) soap_app.transport = "http://schemas.xmlsoap.org/soap/http" return soap_app
def build_app(service_list, tns, name): app = Application(service_list, tns, name) app.transport = 'http://schemas.xmlsoap.org/soap/http' return app
#return the order unique id logger.info("Backoffice: Returning async request for submit order") return new_order.id @soap(Integer, Integer, Auth, _returns=String) def getBudgetResponse(self, order, price, auth): if is_valid_request(auth): create_budget(auth.user_id, order, price) verify_and_finalize_order(order) @soap(Integer, String, Auth, _returns=String) def setStatusOrder(self, order, status, auth): if is_valid_request(auth): Notificator(order).notificate_frontend(status) return "OK" if __name__ == "__main__": host = sys.argv[1] port = int(sys.argv[2]) soap_application = Application([MusicService, OrderService], 'tns') wsgi_application = wsgi.Application(soap_application) server = make_server(host, port, wsgi_application) logger.info("Backoffice serving on %s:%s" % ( host, port, )) server.serve_forever()
def __init__(self, tns, environ=None): super(DefinitionBase, self).__init__(environ) self.soap_app = Application(self, tns, False) self.soap_handler = BaseServer(self.soap_app)
computerid_seq = 1 class Computer(ClassModel): __namespace__ = "assets" assetid = Integer description = String class ComputerManager(DefinitionBase): @soap(Computer, _returns=Computer) def add_computer(self, computer): global computer_database global computerid_seq computer.assetid = computerid_seq computerid_seq += 1 computer_database[computer.assetid] = computer return computer.assetid if __name__ == "__main__": from wsgiref.simple_server import make_server soap_app = Application([ComputerManager, UserManager],tns="itServices") wsgi_app = wsgi.Application(soap_app) server = make_server("localhost", 7789, wsgi_app) server.serve_forever()
def as_view(cls): soap_application = Application([cls], __name__) return DjangoSoapApp(soap_application)
def form_valid(self, form): slug = form.cleaned_data['slug'] return HttpResponseRedirect( reverse('list_order', args=[slug]) ) class ListOrderView(DetailView): context_object_name = 'order' model = Order template_name = 'list_order.html' @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super(ListOrderView, self).dispatch(*args, **kwargs) class OrderStatusService(DefinitionBase): @soap(Integer, String, _returns=String) def changeStatusOrder(self, order, status): Order.objects.filter(slug=int(order)).update(status=status) return "OK" orderstatus_service = DjangoSOAPAdaptor( Application( [OrderStatusService], 'tns' ) )
return user_database[userid] @soap(User) def modify_user(self, user): global user_database user_database[user.userid] = user @soap(Integer) def delete_user(self, userid): global user_database del user_database[userid] @soap(_returns=Array(User)) def list_users(self): global user_database return [v for k, v in user_database.items()] if __name__ == '__main__': try: from wsgiref.simple_server import make_server soap_app = Application([UserManager], 'tns') wsgi_app = wsgi.Application(soap_app) server = make_server('localhost', 7789, wsgi_app) server.serve_forever() except ImportError: print "Error: example server code requires Python >= 2.5"
print 'dm invoke ok!' resInfo = ResultInfo() resInfo.reqNo = reqNo resInfo.resMsg = rs[0] #print resInfo return resInfo class TestService(DefinitionBase): #WebService Method @soap(TestRequestInfo, _returns=ResultInfo) def getResultInfo(self, reqInfo): resInfo = ResultInfo() resInfo = exeRules(reqInfo) #print resInfo return resInfo if __name__ == '__main__': try: print '服务已启动' from wsgiref.simple_server import make_server soap_application = Application([TestService], 'tns') wsgi_application = wsgi.Application(soap_application) server = make_server('localhost', 8899, wsgi_application) server.serve_forever() except ImportError: print 'error'
''' class SleepingService(DefinitionBase): @soap(Integer, _is_async=True) def sleep(self, seconds): msgid, replyto = get_callback_info() def run(): time.sleep(seconds) client = make_service_client(replyto, self) client.woke_up('good morning', msgid=msgid) Thread(target=run).start() @soap(String, _is_callback=True) def woke_up(self, message): pass if __name__ == '__main__': try: from wsgiref.simple_server import make_server soap_app = Application([SleepingService], 'tns') wsgi_app = wsgi.Application(soap_app) server = make_server('localhost', 7789, wsgi_app) server.serve_forever() except ImportError: print "Error: example server code requires Python >= 2.5"