472,353 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

SimpleXMLRPCServer runnning as a Windows Service using win32serviceutil

I am trying to create a Windows service using SimpleXMLRPCServer and
win32serviceutil. The service itself seems to be working properly
(starts, stops, etc) and I can connect using an XMLRPC client from the
localhost. However when I connect from a remote client, I either get a
socket error or an xmlrpclib.ProtocolError error. If I use
serve_forever() rather than handle_request(), the remote clients can
connect but it breaks the Windows service functionality (can't stop the
service). I have tried the same code without the service and that
works, both locally and remotely. It would seem that the problem is
related to the way the service handles remote connections, but I cannot
figure out what the problem is.

I have searched around, but can't find any example code. Hopefully
someone can point me in the right direction.


## XML-RPC Service
import win32serviceutil
import win32service
import win32event
import win32evtlogutil
import win32file
import servicemanager
import SimpleXMLRPCServer

class OBJECT:
def hello(self):
return "Hello World"

class XMLRPCSERVICE(win32serviceutil.ServiceFramework):
_svc_name_ = "XMLRPCSERVICE"
_svc_display_name_ = "XMLRPCSERVICE"
_svc_description_ = "XMLRPCSERVICE"

def __init__(self, args):
win32evtlogutil.AddSourceToRegistry(self._svc_disp lay_name_,
sys.executable, "Application")
win32serviceutil.ServiceFramework.__init__(self, args)

self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.hSockEvent = win32event.CreateEvent(None, 0, 0, None)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING)

def SvcDoRun(self):
## Write a started event
(self._svc_name_, ' (%s)' % self._svc_name_))

server = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 8080))
object = OBJECT()

while 1:
rc =
win32event.WaitForMultipleObjects((self.hWaitStop, self.hSockEvent), 0,
if rc == win32event.WAIT_OBJECT_0:
win32file.WSAEventSelect(server,self.hSockEvent, 0)
#server.serve_forever() ## Works, but breaks the
Windows service functionality

## Write a stopped event



if __name__ == '__main__':

##XML-RPC Server without service, this works using handle_request()
import SimpleXMLRPCServer

#The server object
class OBJECT:
def hello(self):
return "Hello World"

object = OBJECT()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 8080))

#Go into the main listener loop
print "Listening on port 8080"
while 1:

## XML-RPC Client
import xmlrpclib

server = xmlrpclib.ServerProxy("http://remoteserver:8080")
print server.hello()

Apr 26 '06 #1
0 1877

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: D | last post by:
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a...
by: rodmc | last post by:
Hello, I am trying to figure out how to write a windows service, I am totally new to it. I have written a simple test case, however it doesn't...
by: Rudy Schockaert | last post by:
After some Googling I found a post of someone who wanted to do exactly as what I want to do now. There is however a problem in his code that makes...
by: momobear | last post by:
I feel really puzzled about fellowing code, please help me finger out what problem here. import threading class...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.