Automation wrapped xmlrpc Server

Discussion in 'Python' started by =?ISO-8859-1?Q?Juan_Carlos_CORU=D1A?=, Jul 3, 2003.

  1. Hello all,

    I'm trying to create a COM Server with an embedded xmlrpc server.

    Here is way it must work:
    - The client application (programmed with a COM capable language)
    instantiates my COM server (programmed with python).
    - The COM server must have a connect interface in order to let the
    client application process the xmlrpc request.
    - After executing a "serveforever" method on the COM server it begins
    to listen on a configured port for xmlrpc requests.
    - When the COM server receives a xmlrpc request it passes this request
    to the client application event (connect interface) in order to
    process it.
    - The client application processes the request and returns a result to
    the COM server. The COM server returns this result to the xmlrpc
    requester.

    So, I must say that I have programmed some COM servers in python with
    the aid of Mark's book, but in this case I have some problems:
    - Must I instantiate a new thread for the xmlrpc server?
    - If the xmlrpc server is a different thread how can this thread call
    the _BroadcastNotify method from the main thread (the COM server)?
    - I have successfully called the _BroadcastNotify method from the main
    thread, but I become a strange behaviuor calling it from other thread.
    - I tryied to pass the calling object reference to the xmlrpc thread,
    so the xmlrpc thread has a reference to the _BroadcastNotify method,
    but it does not work correctly.

    Here is part of my code (I have deleted some parts):

    class xmlrpcServer(Thread):
    def __init__(self, mainthread, host, port):
    Thread.__init__(self)
    self.host = host
    self.port = port
    self.mainthread = mainthread
    def run(self):
    while 1:
    # the following line simulates the reception
    # of a xmlrpc request
    request = xmlrpcRequest('testmethod', [n, 'parameter2'])
    wrapped = wrap(request, useDispatcher=useDispatcher)
    self.mainthread._BroadcastNotify(self.mainthread.NotifyCall,
    (wrapped,))


    class COMServer(ConnectableServer):
    _public_methods_ = ['Serve'] + ConnectableServer._public_methods_
    _connect_interfaces_ = [IID_IxmlrpcEvents]

    def __init__(self):
    ConnectableServer.__init__(self)
    self.Host = ''
    self.Port = None

    def Serve(self):
    # method Serve
    #req = xmlrpcRequest('testmethod', ['parameter1', 23])
    #wrapped = wrap(req, useDispatcher=useDispatcher)
    #self._BroadcastNotify(self.NotifyCall, (wrapped,))
    #req = unwrap(wrapped)
    self._s = xmlrpcServer(self)
    self._s.start()

    def NotifyCall(self, interface, arg):
    interface.Invoke(1000, 0, pythoncom.DISPATCH_METHOD, 1, arg)

    class xmlrpcRequest:
    # wraps a xmlrpc request as a COM object in order to pass it to
    # a client event
    _public_methods_ = ['Method', 'Parameter', 'Result']

    def __init__(self, method, parameters):
    self.Result = None
    self._method = method
    self._parameters = parameters



    If I call the _BroadcastNotify method directly from the Serve method,
    it works correctly.

    Has anybody examples of a similar COM server?
    Helps will be appreciated.

    Thank you.
     
    =?ISO-8859-1?Q?Juan_Carlos_CORU=D1A?=, Jul 3, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Kratz

    xmlrpc server on red hat 9 question

    Jason Kratz, Jun 29, 2003, in forum: Python
    Replies:
    0
    Views:
    841
    Jason Kratz
    Jun 29, 2003
  2. Mark McClain

    xmlrpc server

    Mark McClain, Oct 17, 2003, in forum: Python
    Replies:
    0
    Views:
    400
    Mark McClain
    Oct 17, 2003
  3. Brian Quinlan

    RE: xmlrpc server

    Brian Quinlan, Oct 17, 2003, in forum: Python
    Replies:
    1
    Views:
    421
    A.M. Kuchling
    Oct 19, 2003
  4. Etienne Posthumus
    Replies:
    1
    Views:
    1,389
    Roger Binns
    Apr 1, 2004
  5. Thomas
    Replies:
    1
    Views:
    463
    Peter Hansen
    Sep 14, 2004
  6. john14
    Replies:
    2
    Views:
    492
    Adonis
    Feb 19, 2005
  7. apondu
    Replies:
    0
    Views:
    748
    apondu
    Jul 19, 2007
  8. Zihong Lu

    .net client + Axis 1.1 server + wrapped param: null result

    Zihong Lu, Jun 18, 2004, in forum: ASP .Net Web Services
    Replies:
    13
    Views:
    498
    Zihong Lu
    Jun 23, 2004
Loading...