SOAP (for Simple Object Access Protocol) is another way to make remote function calls using XML over HTTP. SOAP and XML-RPC were both developed as part of the same project; XML-RPC is basically an early working version of what eventually became SOAP. While XML-RPC was intentionally kept simple, SOAP grew to become more powerful and more complicated.
Here's an example of the SOAP XML format, calling the function echo with the string argument 'cheese':
cheese
And here's the XML returned from the server:
You said: cheese
Twisted uses an external library called SOAPpy to create and parse SOAP messages. You'll have to install SOAPpy to run the next two examples. SOAPpy also requires two additional libraries to be installed: PyXML and fpconst.
To install PyXML, download the package for your platform from http://pyxml.sourceforge.net. If there is an installer available, use it to install PyXML. Otherwise, you can install from the source by extracting the package, entering the package directory, and running the command python setup.py install. You can test to make sure PyXML is installed correctly by importing it in a Python shell:
$ python Python 2.4.1 (#2, Apr 14 2005, 09:13:52) [GCC 4.0.0 20050413 (prerelease) (Debian 4.0-0pre11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import xml >>> xml._ _version_ _ '0.8.4'
The xml._ _version_ _ property should be the same as the PyXML package you installed.
The next prerequisite for SOAPpy is fpconsta Python library for working with floating-point special values. fpconst doesn't have installer packages available, so you'll have to install from the source. Download and extract the latest version. In the directory containing the extracted files, run the command python setup.py install. Once the install is completed, you can verify that fpconst is correctly installed by importing it in a Python shell:
$ python Python 2.4.1 (#2, Apr 14 2005, 09:13:52) [GCC 4.0.0 20050413 (prerelease) (Debian 4.0-0pre11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import fpconst >>> fpconst._ _version_ _ '0.6.0'
Now that the dependencies are installed, you can install SOAPpy. Like fpconst, it's available only as a source package. Download the latest release from http://pywebsvcs.sourceforge.net/ and extract it. In the directory containing the extracted files, run the command python setup.py install to install SOAPpy. Again, it's a good idea to make sure the install was successful by importing the module:
$ python Python 2.4.1 (#2, Apr 14 2005, 09:13:52) [GCC 4.0.0 20050413 (prerelease) (Debian 4.0-0pre11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import SOAPpy >>> SOAPpy._ _version_ _ '0.11.3'
|
Getting Started
Building Simple Clients and Servers
Web Clients
Web Servers
Web Services and RPC
Authentication
Mail Clients
Mail Servers
NNTP Clients and Servers
SSH
Services, Processes, and Logging