source: TI12-security/trunk/python/Tests/xmlsec/WS-Security/wsClient.py @ 1469

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/xmlsec/WS-Security/wsClient.py@1469
Revision 1469, 1.7 KB checked in by pjkersha, 13 years ago (diff)

Working version with signature and validation across a SOAP interface.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3"""WS-Security test client
4
5NERC Data Grid Project
6
7P J Kershaw 01/09/06
8
9Copyright (C) 2006 CCLRC & NERC
10
11This software may be distributed under the terms of the Q Public License,
12version 1.0 or later.
13"""
14
15reposID = '$Id$'
16
17import sys, socket
18from ZSI import Binding, TCcompound, TC
19from wsInterface import *
20import wsSecurity
21
22MESSAGE = "Hello from Python!"
23
24def main():
25   
26    # Signature handler object is passed to binding
27    signatureHandler = wsSecurity.SignatureHandler(\
28                                certFilePath='../../Junk-cert.pem',
29                                priKeyFilePath='../../Junk-key.pem',
30                                priKeyPwd=open('../../tmp2').read().strip())
31
32    binding = Binding(url='http://localhost:8080/wsServer.py',
33                      sig_handler=signatureHandler)
34                 
35    echoRequest = echoRequestWrapper()
36    echoRequest._message = MESSAGE
37   
38    import pdb;pdb.set_trace()
39    print ' Sending: %s' % MESSAGE
40   
41    try:
42        binding.Send(None, 
43                 'echo', 
44                 echoRequest,
45                 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/")
46   
47        response = binding.Receive(echoResponseWrapper(), 
48                 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/")
49
50    except socket.error, (errNum, errMsg):
51        print >>sys.stderr, "Socket error: %s" % errMsg
52        sys.exit(1)
53       
54    if not isinstance(response, echoResponse) and \
55       not issubclass(echoResponse, response.__class__):
56        print >>sys.stderr, "%s incorrect response type" % response.__class__
57        sys.exit(1)
58
59    print 'Response: %s' % response._message
60
61
62if __name__ == '__main__':
63    main()
Note: See TracBrowser for help on using the repository browser.