From: Sapan Bhatia Date: Tue, 7 Jul 2009 23:40:42 +0000 (+0000) Subject: Checking in soap protocol binding X-Git-Tag: sfa-0.9-0@14641~116 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=6615b5c23f78fd8094b604961152df7c5ba94c4d;p=sfa.git Checking in soap protocol binding --- diff --git a/sfa/util/soapprotocol.py b/sfa/util/soapprotocol.py new file mode 100644 index 00000000..856b19cf --- /dev/null +++ b/sfa/util/soapprotocol.py @@ -0,0 +1,36 @@ +# SOAP-specific code for GeniClient + +import pdb +from ZSI.client import Binding +from httplib import HTTPSConnection + +def xmlrpc_like_callable (soap_callable, *x): + soap_result = soap_callable(*x) + xmlrpc_result = soap_result['Result'] + return xmlrpc_result + +class SFACallable: + def __init__(self, soap_callable): + self.soap_callable = soap_callable + + def __call__(self, *args): + outer_result = self.soap_callable(*args) + return outer_result['Result'] + + +class SFASoapBinding(Binding): + def __getattr__(self, attr): + soap_callable = Binding.__getattr__(self, attr) + return SFACallable(soap_callable) + + +def get_server(url, key_file, cert_file): + auth = { + 'transport' : HTTPSConnection, + 'transdict' : {'cert_file' : cert_file, + 'key_file' : key_file + }, + } + + return SFASoapBinding(url=url, **auth) +