source: TI12-security/trunk/python/Tests/AttAuthority/AttAuthorityServer.py @ 1696

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/AttAuthority/AttAuthorityServer.py@1696
Revision 1696, 2.0 KB checked in by pjkersha, 13 years ago (diff)

Working test code for ZSI Web Service using Twisted:

  • for server, used wsdl2dispatch - but make sure to edit the return types

in AttAuthority_services_server server class stubs to return request, response
tuple as required by Twisted interface. Created .tac file which loads a
sub class of the wsdl2dispatch generated class.

  • tested with standard ZSI client using stubs generated from wsdl2py. Also

tested with Twisted client - stubs generated with wsdl2py including the -w
option.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2#
3# How to build an AttAuthority server using the extended code generation
4#
5import sys
6
7# Import the ZSI stuff you'd need no matter what
8from ZSI.ServiceContainer import ServiceContainer, SOAPRequestHandler
9
10# This is a new method imported to show it's value
11from ZSI.ServiceContainer import GetSOAPContext
12
13# Import the generated Server Object
14from AttAuthority_services_server import AttAuthorityService
15
16   
17# Create a Server implementation
18
19#_____________________________________________________________________________
20class AttAuthoritySOAPRequestHandler(SOAPRequestHandler):
21     """Add a do_GET method to return the WSDL on HTTP GET requests.
22     Please note that the path to the wsdl file is derived from what
23     the HTTP invocation delivers (which is put into the self.path
24     attribute), so you might want to change this addressing scheme.
25     """
26     def do_GET(self):
27         """Return the WSDL file."""         
28         self.send_xml(AttAuthorityService._wsdl)
29         
30     def do_POST(self):
31          """Fudge to get _Dispatch to pick up the correct address
32          - seems to be necessary when putting proxy redirect for port in
33          the wsdl e.g. http://glue.badc.rl.ac.uk/sessionMgr points to the
34          default port for the Session Manager."""
35          self.path = "/AttAuthorityServIn"
36          SOAPRequestHandler.do_POST(self)
37   
38class AttAuthorityImpl(AttAuthorityService):
39
40     def soap_getAttCert(self, ps, **kw):
41         #import pdb;pdb.set_trace()
42         response = AttAuthorityService.soap_getAttCert(self, ps)
43         response.set_element_attCert('ATTRIBUTE CERT')
44         return response
45     
46# Here we set up the server
47serviceContainer = ServiceContainer(('localhost', 5700),
48                RequestHandlerClass=AttAuthoritySOAPRequestHandler)
49
50
51# Create the Inherited version of the server
52import sys
53service = AttAuthorityImpl()
54serviceContainer.setNode(service, url="/AttAuthorityServIn")
55
56try:
57    # Run the service container
58    serviceContainer.serve_forever()
59except KeyboardInterrupt:
60    sys.exit(0)
Note: See TracBrowser for help on using the repository browser.