Copyright (c) 2001, actzero, inc. SOAP.py 0.9.5 - Cayce Ullman (cayce@actzero.com) Brian Matthews (blm@actzero.com) MANIFEST: quickstart.txt ../SOAP.py the library ../SOAPtest.py tests the builder and parser ../echoClient.py an example client ../echoServer.py an example server ../speedTest.py benchmarks the various parsers, compares speed to DOM ../TCtest.py experimental type coercion system tests ../tests/* examples ../validate/* interop client and servers ../bid/* N+I interop client and server HOWTO: The easiest ways to understand use of complex types is to look at examples of working code, to look at the wiredumps, and to write new client and server implementations. SOAP.py has a Header class to hold data for the header of a SOAP message. Each Header instance has methods to set/get the MustUnderstand attribute, and methods to set/get the Actor attribute. SOAP.py also has a SOAPContext class so that each server method can be implemented in such a way that it gets the context of the connecting client. This includes both common SOAP information and connection information (see below for an example). CLIENT EXAMPLES: ## CODE import SOAP test = 42 server = SOAP.SOAPProxy("http://localhost:8888") server = server._sa ("urn:soapinterop") hd = SOAP.Header() hd.InteropTestHeader ='This should fault, as you don\'t understand the header.' hd._setMustUnderstand ('InteropTestHeader', 0) hd._setActor ('InteropTestHeader','http://schemas.xmlsoap.org/soap/actor/next') server = server._hd (hd) print server.echoInteger (test) ## /CODE This should succeed (provided the server has defined echoInteger), as it builds a valid header into this client with MustUnderstand set to 0 and then sends the SOAP with this header. ## CODE import SOAP test = 42 server = SOAP.SOAPProxy("http://localhost:8888") server = server._sa ("urn:soapinterop") #Header hd = SOAP.Header() hd.InteropTestHeader = 'This should fault,as you don\'t understand the header.' hd._setMustUnderstand ('InteropTestHeader', 1) hd._setActor ('InteropTestHeader','http://schemas.xmlsoap.org/soap/actor/next') server = server._hd (hd) print server.echoInteger (test) ## /CODE This should fail (even if the server has defined 'echoInteger'), as it builds a valid header into this client, but sets MustUnderstand to 1 for a message that the server presumably won't understand before sending. SERVER EXAMPLES: ## CODE import SOAP def echoInteger (inputInteger): return inputInteger server = SOAP.SOAPServer ( ('localhost', 8080) ) server.registerFunction (echoInteger) server.serve_forever() ## /CODE This is a simple server designed to work with the first 2 clients above. ## CODE import SOAP def echoInteger (inputInteger, _SOAPContext): c = _SOAPContext print c.xmldata print c.header print c.body print c.connection.getpeername() print c.soapaction print c.httpheaders return inputInteger host = 'localhost' port = 8888 server = SOAP.SOAPServer ( (host, port) ) server.registerFunction (SOAP.MethodSig(echoInteger, keywords=0,context=1)) server.serve_forever() ## /CODE This is a server which shows off the SOAPContext feature. This server gets a context from the client that has connected to it, and prints some of the pertinent aspects of that client before returning. This server should also work with the code for the two clients written above. Copyright (c) 2001, actzero, inc. Copyright (c) 2001, Cayce Ullman. All rights reserved. LICENSE: -------------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of actzero, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.