8d9b3d15f27a028c2ebefa063cce10768791139a
[sfa.git] / sfa / util / soapprotocol.py
1 # SOAP-specific code for SFA Client
2
3 import pdb
4 from ZSI.client import Binding
5 from httplib import HTTPSConnection
6
7 def xmlrpc_like_callable (soap_callable, *x):
8     soap_result = soap_callable(*x)
9     xmlrpc_result = soap_result['Result']
10     return xmlrpc_result
11         
12 class SFACallable:
13      def __init__(self, soap_callable):
14         self.soap_callable = soap_callable
15
16      def __call__(self, *args):
17          outer_result = self.soap_callable(*args)
18          return outer_result['Result']
19
20
21 class SFASoapBinding(Binding):
22     def __getattr__(self, attr):
23         soap_callable = Binding.__getattr__(self, attr)
24         return SFACallable(soap_callable)
25
26
27 def get_server(url, key_file, cert_file):
28     auth = {
29         'transport' : HTTPSConnection,
30         'transdict' : {'cert_file' : cert_file, 
31                        'key_file' : key_file
32                       },
33      }
34
35     return SFASoapBinding(url=url, **auth)
36