Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > a709ddb20745c7012e3d3a00b31ca2a7 > files > 255

python-ZSI-2.0-6.fc13.noarch.rpm


BACKGROUND
==========

This is a simple example of the new additions I've been adding to
ZSI. Among these modifications are:

1) Extended code generation facilities for server and client
2) Authorization callbacks
3) ServiceContainer enhancements for implementations to use


Extended Code Generation for Server and Client
----------------------------------------------

These extensions are illustrated by the Echo.wsdl, EchoServer.py and
EchoClient.py that implement an Echo service. The EchoServer.py file
has two classes defined that implement the Echo functionality, the
difference in the two is that one inherits from the generated
EchoServer_interface class (generated by wsdl2dispatch), and one can
be passed to the EchoServer_interface constructor with the keyword
argument impl=<obj>.

These two solutions follow the classic TIE and Derive patterns from
previous systems like CORBA.

The EchoClient.py implements a simple client for each service and
invokes the method to do the work. The second call is programmed to
result in an authorization error.

Authorization Callbacks
-----------------------

This functionality lets you define a method on your implementation
object that can be invoked to authorize calls to it from the
underlying SOAP interface. 

ServiceContainer Enhancements
-----------------------------

I've added the ability to get a CallContext via a ServiceContainer
module level function GetSOAPContext(). This returns a context object
for the current request. I've make this thread-safe by keeping a
global dictionary of contexts indexed by thread id. The requesthandler
object cleanly creates and destroys these for each incoming request.

The SOAPContext contains:

- a reference to the connection object
- a reference to the Service Container
- the HTTP headers
- the raw xml of the request
- the Parsed SOAP object
- the SOAP Action

This should provide all the information a developer could need.

BUILDING
========

You should (with a fresh checkout from cvs that's been installed) be able to run:

>wsdl2py -e -f Echo.wsdl --simple-naming
>wsdl2dispatch -e -f Echo.wsdl --simple-naming

Then in separate terminal windows:

Terminal 1:
>python EchoServer.py

Terminal 2:
>python EchoClient.py

Expected SERVER Output:

C:\xfer\Echo-extended>EchoServer.py
Authorizing TIE Echo
['__doc__', '__init__', '__module__', 'connection', 'container', 'httpheaders',
'parsedsoap', 'soapaction', 'xmldata']
Container:  <socket._socketobject object at 0x00C03030>
Parsed SOAP:  <ZSI.parse.ParsedSoap instance at 0x00C00878>
Container:  <ZSI.ServiceContainer.ServiceContainer instance at 0x00BEB710>
HTTP Headers:
Host: localhost:9999
Accept-Encoding: identity
Content-length: 551
Content-type: text/xml; charset=utf-8
SOAPAction: "Echo"

----
XML Data:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<SOAP-ENV:Body>
<None  xmlns="">
<in_str id="8fbb88" xsi:type="xsd:string">Test TIE String</in_str>
</None >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

localhost - - [02/Feb/2005 21:35:00] "POST /EchoServer HTTP/1.1" 200 -
NOT Authorizing INHERIT Echo
['__doc__', '__init__', '__module__', 'connection', 'container', 'httpheaders',
'parsedsoap', 'soapaction', 'xmldata']
Container:  <socket._socketobject object at 0x00C03030>
Parsed SOAP:  <ZSI.parse.ParsedSoap instance at 0x00C5EEB8>
Container:  <ZSI.ServiceContainer.ServiceContainer instance at 0x00BEB710>
HTTP Headers:
Host: localhost:9999
Accept-Encoding: identity
Content-length: 555
Content-type: text/xml; charset=utf-8
SOAPAction: "Echo"

----
XML Data:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<SOAP-ENV:Body>
<None  xmlns="">
<in_str id="8f4cb0" xsi:type="xsd:string">Test INHERIT String</in_str>
</None >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

localhost - - [02/Feb/2005 21:35:00] "POST /EchoServIn HTTP/1.1" 401 -

Expected CLIENT Output:

C:\xfer\Echo-extended>EchoClient.py
Test TIE StringTest TIE StringTest TIE String
Failed to echo (Inherited):  Not authorized