1 | |
---|
2 | BACKGROUND |
---|
3 | ========== |
---|
4 | |
---|
5 | This is a simple example of the new additions I've been adding to |
---|
6 | ZSI. Among these modifications are: |
---|
7 | |
---|
8 | 1) Extended code generation facilities for server and client |
---|
9 | 2) Authorization callbacks |
---|
10 | 3) ServiceContainer enhancements for implementations to use |
---|
11 | |
---|
12 | |
---|
13 | Extended Code Generation for Server and Client |
---|
14 | ---------------------------------------------- |
---|
15 | |
---|
16 | These extensions are illustrated by the Echo.wsdl, EchoServer.py and |
---|
17 | EchoClient.py that implement an Echo service. The EchoServer.py file |
---|
18 | has two classes defined that implement the Echo functionality, the |
---|
19 | difference in the two is that one inherits from the generated |
---|
20 | EchoServer_interface class (generated by wsdl2dispatch), and one can |
---|
21 | be passed to the EchoServer_interface constructor with the keyword |
---|
22 | argument impl=<obj>. |
---|
23 | |
---|
24 | These two solutions follow the classic TIE and Derive patterns from |
---|
25 | previous systems like CORBA. |
---|
26 | |
---|
27 | The EchoClient.py implements a simple client for each service and |
---|
28 | invokes the method to do the work. The second call is programmed to |
---|
29 | result in an authorization error. |
---|
30 | |
---|
31 | Authorization Callbacks |
---|
32 | ----------------------- |
---|
33 | |
---|
34 | This functionality lets you define a method on your implementation |
---|
35 | object that can be invoked to authorize calls to it from the |
---|
36 | underlying SOAP interface. |
---|
37 | |
---|
38 | ServiceContainer Enhancements |
---|
39 | ----------------------------- |
---|
40 | |
---|
41 | I've added the ability to get a CallContext via a ServiceContainer |
---|
42 | module level function GetSOAPContext(). This returns a context object |
---|
43 | for the current request. I've make this thread-safe by keeping a |
---|
44 | global dictionary of contexts indexed by thread id. The requesthandler |
---|
45 | object cleanly creates and destroys these for each incoming request. |
---|
46 | |
---|
47 | The SOAPContext contains: |
---|
48 | |
---|
49 | - a reference to the connection object |
---|
50 | - a reference to the Service Container |
---|
51 | - the HTTP headers |
---|
52 | - the raw xml of the request |
---|
53 | - the Parsed SOAP object |
---|
54 | - the SOAP Action |
---|
55 | |
---|
56 | This should provide all the information a developer could need. |
---|
57 | |
---|
58 | BUILDING |
---|
59 | ======== |
---|
60 | |
---|
61 | You should (with a fresh checkout from cvs that's been installed) be able to run: |
---|
62 | |
---|
63 | >wsdl2py -e -f Echo.wsdl --simple-naming |
---|
64 | >wsdl2dispatch -e -f Echo.wsdl --simple-naming |
---|
65 | |
---|
66 | Then in separate terminal windows: |
---|
67 | |
---|
68 | Terminal 1: |
---|
69 | >python EchoServer.py |
---|
70 | |
---|
71 | Terminal 2: |
---|
72 | >python EchoClient.py |
---|
73 | |
---|
74 | Expected SERVER Output: |
---|
75 | |
---|
76 | C:\xfer\Echo-extended>EchoServer.py |
---|
77 | Authorizing TIE Echo |
---|
78 | ['__doc__', '__init__', '__module__', 'connection', 'container', 'httpheaders', |
---|
79 | 'parsedsoap', 'soapaction', 'xmldata'] |
---|
80 | Container: <socket._socketobject object at 0x00C03030> |
---|
81 | Parsed SOAP: <ZSI.parse.ParsedSoap instance at 0x00C00878> |
---|
82 | Container: <ZSI.ServiceContainer.ServiceContainer instance at 0x00BEB710> |
---|
83 | HTTP Headers: |
---|
84 | Host: localhost:9999 |
---|
85 | Accept-Encoding: identity |
---|
86 | Content-length: 551 |
---|
87 | Content-type: text/xml; charset=utf-8 |
---|
88 | SOAPAction: "Echo" |
---|
89 | |
---|
90 | ---- |
---|
91 | XML Data: |
---|
92 | <?xml version="1.0" encoding="utf-8"?> |
---|
93 | <SOAP-ENV:Envelope |
---|
94 | xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" |
---|
95 | xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" |
---|
96 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
---|
97 | xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
---|
98 | xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" |
---|
99 | SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > |
---|
100 | <SOAP-ENV:Body> |
---|
101 | <None xmlns=""> |
---|
102 | <in_str id="8fbb88" xsi:type="xsd:string">Test TIE String</in_str> |
---|
103 | </None > |
---|
104 | </SOAP-ENV:Body> |
---|
105 | </SOAP-ENV:Envelope> |
---|
106 | |
---|
107 | localhost - - [02/Feb/2005 21:35:00] "POST /EchoServer HTTP/1.1" 200 - |
---|
108 | NOT Authorizing INHERIT Echo |
---|
109 | ['__doc__', '__init__', '__module__', 'connection', 'container', 'httpheaders', |
---|
110 | 'parsedsoap', 'soapaction', 'xmldata'] |
---|
111 | Container: <socket._socketobject object at 0x00C03030> |
---|
112 | Parsed SOAP: <ZSI.parse.ParsedSoap instance at 0x00C5EEB8> |
---|
113 | Container: <ZSI.ServiceContainer.ServiceContainer instance at 0x00BEB710> |
---|
114 | HTTP Headers: |
---|
115 | Host: localhost:9999 |
---|
116 | Accept-Encoding: identity |
---|
117 | Content-length: 555 |
---|
118 | Content-type: text/xml; charset=utf-8 |
---|
119 | SOAPAction: "Echo" |
---|
120 | |
---|
121 | ---- |
---|
122 | XML Data: |
---|
123 | <?xml version="1.0" encoding="utf-8"?> |
---|
124 | <SOAP-ENV:Envelope |
---|
125 | xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" |
---|
126 | xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" |
---|
127 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
---|
128 | xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
---|
129 | xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" |
---|
130 | SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > |
---|
131 | <SOAP-ENV:Body> |
---|
132 | <None xmlns=""> |
---|
133 | <in_str id="8f4cb0" xsi:type="xsd:string">Test INHERIT String</in_str> |
---|
134 | </None > |
---|
135 | </SOAP-ENV:Body> |
---|
136 | </SOAP-ENV:Envelope> |
---|
137 | |
---|
138 | localhost - - [02/Feb/2005 21:35:00] "POST /EchoServIn HTTP/1.1" 401 - |
---|
139 | |
---|
140 | Expected CLIENT Output: |
---|
141 | |
---|
142 | C:\xfer\Echo-extended>EchoClient.py |
---|
143 | Test TIE StringTest TIE StringTest TIE String |
---|
144 | Failed to echo (Inherited): Not authorized |
---|