1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | import sys, socket |
---|
4 | from ZSI import Binding, TCcompound, TC |
---|
5 | from wsInterface import * |
---|
6 | import wsSecurity |
---|
7 | |
---|
8 | MESSAGE = "Hello from Python!" |
---|
9 | |
---|
10 | def main(): |
---|
11 | |
---|
12 | # Signature handler object is passed to binding |
---|
13 | signatureHandler = wsSecurity.SignatureHandler(\ |
---|
14 | certFilePath='../../Junk-cert.pem', |
---|
15 | priKeyFilePath='../../Junk-key.pem', |
---|
16 | priKeyPwd=open('../../tmp2').read().strip()) |
---|
17 | |
---|
18 | binding = Binding(url='http://localhost:8080/wsServer.py', |
---|
19 | sig_handler=signatureHandler) |
---|
20 | |
---|
21 | echoRequest = echoRequestWrapper() |
---|
22 | echoRequest._message = MESSAGE |
---|
23 | |
---|
24 | import pdb;pdb.set_trace() |
---|
25 | print ' Sending: %s' % MESSAGE |
---|
26 | |
---|
27 | try: |
---|
28 | txResp = binding.Send(None, |
---|
29 | 'echo', |
---|
30 | echoRequest, |
---|
31 | encodingStyle="http://schemas.xmlsoap.org/soap/encoding/") |
---|
32 | |
---|
33 | rxResp = binding.Receive(echoResponseWrapper(), |
---|
34 | encodingStyle="http://schemas.xmlsoap.org/soap/encoding/") |
---|
35 | |
---|
36 | except socket.error, (errNum, errMsg): |
---|
37 | print >>sys.stderr, "Socket error: %s" % errMsg |
---|
38 | sys.exit(1) |
---|
39 | |
---|
40 | if not isinstance(rxResp, echoResponse) and \ |
---|
41 | not issubclass(echoResponse, rxResp.__class__): |
---|
42 | print >>sys.stderr, "%s incorrect response type" % rxResp.__class__ |
---|
43 | sys.exit(1) |
---|
44 | |
---|
45 | print 'Response: %s' % rxResp._message |
---|
46 | |
---|
47 | |
---|
48 | if __name__ == '__main__': |
---|
49 | main() |
---|