lye-0.1 - a COM to SOAP gateway

Andrew Dalke
Thu, 14 Sep 2000 06:06:50 -0600


               Lye - a COM to SOAP gateway

                      version 0.1

  Lye is a Python program which converts COM requests into SOAP calls.
It uses win32com.server's DynamicPolicy to interpret the COM request
and Fredrick Lundh's soaplib to make the SOAP query.

  Microsoft distributes a similar gateway (I think) but the download
page says it only runs on NT 4.0 SP 6 and Win2000.  I don't have
access to either of those OSes, which is why I rolled my own.

  There are many limitations to this gateway:
   - I don't know much about COM (this is my first COM server)
   - I don't know much about SOAP
   - There's no support on the COM side for keyword arguments
   - soaplib is incomplete and contains some bugs

  Still, it does work for at least the simple case of "use a set of
scalar parameters and return a scalar result" and since the code is
quite short (about 100 lines) it should be easy to hack to fill in any
missing parts.

  Lye is developed and placed into the public domain by Andrew Dalke,
Dalke Scientific Software, LLC.  If you break it, you get to keep all
the pieces.


  Install Python with the win32 extensions, from

  Install soaplib, from
    - Don't forget to add soaplib to the PYTHONPATH registry entry!
    - I've included a couple of soaplib patches in "soaplib.diff"
      which supports passing binary strings and allows soaplib to
      exchange arrays of values with itself.

  Start the default soaplib server with "python"
    - this starts an echo server on the localhost, port 8000

  Run "python" to register the COM server.

Example Python client:

from win32com.client import Dispatch
factory = Dispatch("Lye.Factory")
soap = factory("http://localhost:8000")
print soap.echo("Andrew")

Example VB client:

Sub TestSOAP()
  Set factory = CreateObject("Lye.Factory")
  Set soap = factory("http://localhost:8000")
  MsgBox soap.echo("Andrew")
End Sub

Client API:

   As you can see, it's pretty simple.  There are two objects, the
SOAP Factory and the SOAP ServerProxy.  The factory makes server
proxies when given the URL (okay, URI) for the SOAP server.

  The proxy object can be called using any method name and arguments,
where "any" is defined as "supported by Python's COM interface."

WARNING: because VB doesn't understand case, all method names are
converted to lowercase before calling the SOAP server.  To get around
that, call the proxy object as an indexed object with the method
name as the first parameter and the normal arguments following.

That is, the following fails:
if the SOAP server really implements a FindPrice, but
  soap("FindPrice", "0-123-456")
will work.

This latter interface should be considered experimental, because there
may be a more appropriate way to handle that case using COM.


  To uninstall the Lye COM server, "python --unregister"

                             Andrew Dalke
                             Sept. 14, 2000