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

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

Added simple SOAP client/server interface for incorporation of WS-Security
signature.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3from ZSI import Binding, TCcompound, TC
4from wsInterface import *
5import wsSecurity
6
7MESSAGE = "Hello from Python!"
8
9def main():
10   
11    # Signature handler object is passed to binding
12    signatureHandler = wsSecurity.SignatureHandler(\
13                                certFilePath='../../Junk-cert.pem',
14                                priKeyFilePath='../../Junk-key.pem',
15                                priKeyPwd=open('../../tmp2').read().strip())
16
17    binding = Binding(url='http://localhost:8080/wsServer.py',
18                      sig_handler=signatureHandler)
19                 
20    echoRequest = echoRequestWrapper()
21    echoRequest._message = MESSAGE
22   
23    import pdb;pdb.set_trace()
24    print ' Sending: %s' % MESSAGE
25    txResp = binding.Send(None, 
26                 'echo', 
27                 echoRequest,
28                 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/")
29   
30    rxResp = binding.Receive(echoResponseWrapper(), 
31                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/")
32   
33    if not isinstance(rxResp, echoResponse) and \
34       not issubclass(echoResponse, rxResp.__class__):
35        raise TypeError, "%s incorrect response type" % rxResp.__class__
36
37    print 'Response: %s' % rxResp._message
38
39
40if __name__ == '__main__':
41    main()
Note: See TracBrowser for help on using the repository browser.