Monday, June 29, 2009

Netbeans 6.7 Is Here

Today I downloaded and installed Netbeans 6.7. My first impressions are very good. The performance seems better and I really like what was done for unit testing.

I have used it under Windows and Linux. Thanks Netbeans team!! Another great version delivered right on time.

Tuesday, June 23, 2009

HOWTO: Install Python Soap Libraries ZSI + SOAPpy + PyXML Under (of all things) Windows XP

Overview
I recently needed do some simple scripting using Python under Windows. The main goal was to test some web service calls (via SOAP). Python lets you put something like this together pretty quickly. Including WSDL processing, business logic, and unit testing.

Adding a SOAP library (ZSI+SOAPpy in this case) under linux (ubuntu or fedora) is also simple since you just install a package from a repo. However, I found that setting is up under Windows to be more of a pain.

Problem
Get ZSI, SOAPpy, fpconst, and PyXML setup for use in SOAP programming under Python 2.6.

The main issue is that one of the dependancies, PyXML, does not have a package for versions of Python > 2.4. This means that it will need to be manually built. The typical setup.py usually does the trick but for PyXML a C module was also included as part of the distro. Compiling modules under Windows requires an open source compiler or Visual Studio 2008. For me, neither are an option. Man I wish I could just use linux :-)

Lets Begin
After you fetch the packages through the Python Website...

Install fpconst
This, I think, is needed by SOAPpy. Fetch fpconst-0.7.2.tar.gz
  1. Under Windows I use WinRAR to extract the setup/temp folder
  2. run: python setup.py build
  3. run: python setup.py install
That is done.

Install PyXML
PyXML is required by SOAPpy and possibly ZSI. The problem you will run into installing it is that there are a few Python extensions that need compiled and unless you have Visual Studio 2008, it will not compile under Python 2.6.

Fortunatally, I discovered that SOAPpy (or ZSI) don't use these extensions so as long as you don't need it yourself you can install it as follows.
  1. Under Windows I use WinRAR to extract the setup/temp folder
  2. run: python setup.py install --force -skip-build
The -skip-build skips the building of the C based extension. Without this parameter you will get an error under windows as it looks for Visual Studio 2008. If you have Visual Studio 2008, you are probably not reading this blog and had no issues installing PyXML :-)

Installing SOAPpy
With PyXML installed, the hard part is over.
  1. Unzip SOAPpy-0.12.0.zip to a setup/temp folder
  2. run: python setup.py build
  3. run: python setup.py install
That is done.

Install ZSI
Now the dependencies are install, ZSI can be installed. This is what you will use for all your SOAP calls. It is pretty well documented and fairly easy to use. The approach is similar to how it is handled in Java or .NET. Install is simple
  1. WinRAR ZSI-2.0.tar.gz to a setup/temp folder
  2. run: python setup.py build
  3. run: python setup.py install
That is done

Does it work?
To test, you will first need to process your web service WSDL file into something Python can work with. The approach is similar to what is done when you add a web service reference in .NET or JAVA. This this case, you use a simple command line utility called wsdl2py. On my windows computer, it is found in C:\Python26\Scripts\ You should find it in a similar place. Assuming that you do not have this script in the path and have not been clever enough to make a batch file, you can run it as follows. CD to the directory where you want your PY files created by the utility to go.

python C:\Python26\Scripts\wsdl2py -bu http://moneycow.sandwich.lan:8888/moneyfinder.asmx?WSDL

There are more parameters, but this command will get you what you need. You may see a few deprecation warnings but they don't hurt anything. In the end, you will get two files.
  • *_services.py
  • *_services_types.py
Or similar. Read the ZSI docs on how to use them. I will try to post a blog soon with an example.

Unknowns
I have not figured out how to get SSL to work with ZSI. If any of you have figured this out, please post me a message. I would love to hear about it. It is not an issue for me now since none of the services I need to consume are Internet exposed. If I get stuck and need to access one, I will just use Java or .NET ;-)

Conclusion
If you have to use Windows and need to do Web Services with Python 2.6, the above steps should get you setup and ready to role. Once you are setup and get your first basic program working, you will find that Python does a good job and the performance is just fine.