def main(): logging.getLogger().setLevel(logging.DEBUG) logging.info("Starting...") config = Config("/etc/pyvision/server.conf") config.load() dispatch.AsServer(port=8080) logging.info("Exiting...")
#!/usr/bin/env python from ZSI import dispatch from Example_services import * def echo(message): response = EchoResponseWrapper() response._Message = message return response if __name__ == '__main__': dispatch.AsServer(port=8080)
return lineages def structType2dict(struct): """Converts a SOAPpy structType object to a Python dictionary""" return dict((key, getattr(struct, key)) for key in struct._keys()) def getLineageCode(species, kingdoms=KINGDOMS): kingdoms = structType2dict(kingdoms) lineage = getLineage(species) try: first_species = lineage.keys()[0] except IndexError: return None for l in lineage[ first_species]: # we only do the first species in the lineage results for n in l: if n in kingdoms: return kingdoms[n] return None if USE_ZSI: # if using ZSI instead of SOAPpy dispatch.AsServer(port=8999) else: server = SOAPpy.SOAPServer(("localhost", 8999)) server.registerFunction(getLineageCode) server.serve_forever()
#!/usr/bin/env python from ZSI import dispatch from ComplexTypes import User def GetUser(user_id): user = User(user_id, 'John Doe', 28) return user if __name__ == '__main__': nsdict = {'types': 'http://pycon.org/types'} dispatch.AsServer(port=8080, nsdict=nsdict)
#!/usr/bin/env python #A ZSI server to handle our requests #Import the ZSI machinery from ZSI import dispatch LARGE_STRING = "this is a large string" * 1000 def receiveLargeString(data): #print "Recieved String of size %d" % len(data) pass def sendLargeString(): return LARGE_STRING def receiveInt(data): #print "Recived Int %d" % data #print type(data) pass print "Starting server..." dispatch.AsServer(port=8888)
#!/usr/bin/env python from ZSI import dispatch import Registration_services_types from Registration_services import RegisterUserResponseWrapper def RegisterUser(user): response = RegisterUserResponseWrapper() response._Message = "OK" return response if __name__ == '__main__': dispatch.AsServer(port=8080, typesmodule=(Registration_services_types, ))
#!/usr/bin/env python from ZSI import dispatch import ComplexTypes as MyComplexTypes def RegisterUser(user): return "OK" if __name__ == '__main__': dispatch.AsServer(port=8080, typesmodule=(MyComplexTypes, ))