source: TI12-security/trunk/python/Tests/Echo/EchoServer.py @ 1542

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/Echo/EchoServer.py@1546
Revision 1542, 2.2 KB checked in by pjkersha, 14 years ago (diff)

Added http proxy handling for ZSI - see Tests/Echo?/urllib2Client.py

  • Property svn:executable set to *
Line 
1#!/bin/env python
2#
3# How to build an echo server using the extended code generation
4#
5
6# Import the ZSI stuff you'd need no matter what
7from ZSI.ServiceContainer import ServiceContainer
8
9# This is a new method imported to show it's value
10from ZSI.ServiceContainer import GetSOAPContext
11
12# Import the generated Server Object
13import EchoServer_interface
14
15# Create a Server implementation
16
17# Here we use a Tie approach
18#class EchoServer:
19#    def authorize(self, auth_info, post, action):
20#        print "Authorizing TIE Echo"
21#        ctx = GetSOAPContext()
22#        print dir(ctx)
23#        print "Container: ", ctx.connection
24#        print "Parsed SOAP: ", ctx.parsedsoap
25#        print "Container: ", ctx.container
26#        print "HTTP Headers:\n", ctx.httpheaders
27#        print "----"
28#        print "XML Data:\n", ctx.xmldata
29#        return 0
30#
31#    def Echo(self, input):
32#        return input * 3
33   
34# This using a derived server instead
35class EchoServIn(EchoServer_interface.EchoServer):
36    def __init__(self, post='', **kw):
37        EchoServer_interface.EchoServer.__init__(self, post, **kw)
38
39        # Fudge to copy methods of this class so that equivalent
40        # SimpleCAService class WS stub picks it up
41        self.impl = self
42       
43    def authorize(self, auth_info, post, action):
44        print "Authorizing INHERIT Echo"
45        ctx = GetSOAPContext()
46        print dir(ctx)
47        print "Container: ", ctx.connection
48        print "Parsed SOAP: ", ctx.parsedsoap
49        print "Container: ", ctx.container
50        print "HTTP Headers:\n", ctx.httpheaders
51        print "----"
52        print "XML Data:\n", ctx.xmldata
53        return 1
54
55    def Echo(self, input):
56        import pdb;pdb.set_trace()
57        return input * 3
58
59# Here we set up the server
60serviceContainer = ServiceContainer(('localhost', 7000))
61
62# Create the TIE version of the server
63#hws = EchoServer()
64#hwsi = EchoServer_interface.EchoServer(impl=hws,
65#                                       auth_method_name="authorize")
66#serviceContainer.setNode(hwsi, url="/EchoServer")
67
68# Create the Inherited version of the server
69import sys
70hws2 = EchoServIn(tracefile=sys.stdout)
71serviceContainer.setNode(hws2, url="/EchoServIn")
72
73# Run the service container
74serviceContainer.serve_forever()
Note: See TracBrowser for help on using the repository browser.