Index: fedd/fedd_experiment_control.py
===================================================================
--- fedd/fedd_experiment_control.py	(revision f8582c9a024862e2f99c61a303029f0c7929d8b3)
+++ fedd/fedd_experiment_control.py	(revision 058f58e973a0a88bc6106dbaec3f9760e7823f79)
@@ -145,4 +145,16 @@
 		self.pdata.terminate()
 
+    call_RequestAccess = service_caller('RequestAccess',
+	    'getfeddPortType', feddServiceLocator, 
+	    RequestAccessRequestMessage, 'RequestAccessRequestBody')
+
+    call_ReleaseAccess = service_caller('ReleaseAccess',
+	    'getfeddPortType', feddServiceLocator, 
+	    ReleaseAccessRequestMessage, 'ReleaseAccessRequestBody')
+
+    call_Ns2Split = service_caller('Ns2Split',
+	    'getfeddInternalPortType', feddInternalServiceLocator, 
+	    Ns2SplitRequestMessage, 'Ns2SplitRequestBody')
+
     def __init__(self, config=None):
 	"""
@@ -242,25 +254,25 @@
 	# Dispatch tables
 	self.soap_services = {\
-		'Create': make_soap_handler(\
+		'Create': soap_handler(\
 			CreateRequestMessage.typecode,
 			getattr(self, "create_experiment"), 
 			CreateResponseMessage,
 			"CreateResponseBody"),
-		'Vtopo': make_soap_handler(\
+		'Vtopo': soap_handler(\
 			VtopoRequestMessage.typecode,
 			getattr(self, "get_vtopo"),
 			VtopoResponseMessage,
 			"VtopoResponseBody"),
-		'Vis': make_soap_handler(\
+		'Vis': soap_handler(\
 			VisRequestMessage.typecode,
 			getattr(self, "get_vis"),
 			VisResponseMessage,
 			"VisResponseBody"),
-		'Info': make_soap_handler(\
+		'Info': soap_handler(\
 			InfoRequestMessage.typecode,
 			getattr(self, "get_info"),
 			InfoResponseMessage,
 			"InfoResponseBody"),
-		'Terminate': make_soap_handler(\
+		'Terminate': soap_handler(\
 			TerminateRequestMessage.typecode,
 			getattr(self, "terminate_experiment"),
@@ -270,17 +282,17 @@
 
 	self.xmlrpc_services = {\
-		'Create': make_xmlrpc_handler(\
+		'Create': xmlrpc_handler(\
 			getattr(self, "create_experiment"), 
 			"CreateResponseBody"),
-		'Vtopo': make_xmlrpc_handler(\
+		'Vtopo': xmlrpc_handler(\
 			getattr(self, "get_vtopo"),
 			"VtopoResponseBody"),
-		'Vis': make_xmlrpc_handler(\
+		'Vis': xmlrpc_handler(\
 			getattr(self, "get_vis"),
 			"VisResponseBody"),
-		'Info': make_xmlrpc_handler(\
+		'Info': xmlrpc_handler(\
 			getattr(self, "get_info"),
 			"InfoResponseBody"),
-		'Terminate': make_xmlrpc_handler(\
+		'Terminate': xmlrpc_handler(\
 			getattr(self, "terminate_experiment"),
 			"TerminateResponseBody"),
@@ -816,46 +828,11 @@
 	    req['resources']['node'] = rnodes
 
-	# No retry loop here.  Proxy servers must correctly authenticate
-	# themselves without help
-
-	try:
-	    ctx = fedd_ssl_context(self.cert_file, 
-		    self.trusted_certs, password=self.cert_pwd)
-	except SSL.SSLError:
-	    raise service_error(service_error.server_config, 
-		    "Server certificates misconfigured")
-
-	loc = feddServiceLocator();
-	port = loc.getfeddPortType(uri,
-		transport=M2Crypto.httpslib.HTTPSConnection, 
-		transdict={ 'ssl_context' : ctx })
-
-	# Reconstruct the full request message
-	msg = RequestAccessRequestMessage()
-	msg.set_element_RequestAccessRequestBody(
-		pack_soap(msg, "RequestAccessRequestBody", req))
-
-	try:
-	    resp = port.RequestAccess(msg)
-	except ZSI.ParseException, e:
-	    raise service_error(service_error.req,
-		    "Bad format message (XMLRPC??): %s" % str(e))
-	except ZSI.FaultException, e:
-	    resp = e.fault.detail[0]
-
-	# Again, weird incompatibilities rear their head.  userRoles, which are
-	# restricted strings, seem to be encoded by ZSI as non-unicode strings
-	# in a way that confuses the pickling and XMLRPC sending systems.
-	# Explicitly unicoding them seems to fix this, though it concerns me
-	# some.  It may be that these things are actually a ZSI string
-	# subclass, and the character encoding is not the major issue.  In any
-	# case, making all the subclasses of basestring into unicode strings
-	# unifies the response format and solves the problem.
-	r = make_unicode(fedids_to_obj(unpack_soap(resp)))
+	r = self.call_RequestAccess(uri, req, 
+		self.cert_file, self.cert_pwd, self.trusted_certs)
 
 	if r.has_key('RequestAccessResponseBody'):
 	    r = r['RequestAccessResponseBody']
 	else:
-	    raise service_error(service_error.proxy,
+	    raise service_error(service_error.protocol,
 		    "Bad proxy response")
 
@@ -894,33 +871,6 @@
 		    "Unknown testbed: %s" % tb)
 
-	# The basic request
-	req = { 'allocID' : aid }
-
-	# No retry loop here.  Proxy servers must correctly authenticate
-	# themselves without help
-	try:
-	    ctx = fedd_ssl_context(self.cert_file, 
-		    self.trusted_certs, password=self.cert_pwd)
-	except SSL.SSLError:
-	    raise service_error(service_error.server_config, 
-		    "Server certificates misconfigured")
-
-	loc = feddServiceLocator();
-	port = loc.getfeddPortType(uri,
-		transport=M2Crypto.httpslib.HTTPSConnection, 
-		transdict={ 'ssl_context' : ctx })
-
-	# Reconstruct the full request message
-	msg = ReleaseAccessRequestMessage()
-	msg.set_element_ReleaseAccessRequestBody(
-		pack_soap(msg, "ReleaseAccessRequestBody", req))
-
-	try:
-	    resp = port.ReleaseAccess(msg)
-	except ZSI.ParseException, e:
-	    raise service_error(service_error.req,
-		    "Bad format message (XMLRPC??): %s" % str(e))
-	except ZSI.FaultException, e:
-	    resp = e.fault.detail[0]
+	resp = self.call_ReleaseAccess(uri, {'allocID': aid},
+		self.cert_file, self.cert_pwd, self.trusted_certs)
 
 	# better error coding
@@ -934,30 +884,7 @@
 	    }
 
-	# No retry loop here.  Proxy servers must correctly authenticate
-	# themselves without help
-	try:
-	    ctx = fedd_ssl_context(self.cert_file, 
-		    self.trusted_certs, password=self.cert_pwd)
-	except SSL.SSLError:
-	    raise service_error(service_error.server_config, 
-		    "Server certificates misconfigured")
-
-	loc = feddInternalServiceLocator();
-	port = loc.getfeddInternalPortType(uri,
-		transport=M2Crypto.httpslib.HTTPSConnection, 
-		transdict={ 'ssl_context' : ctx })
-
-	# Reconstruct the full request message
-	msg = Ns2SplitRequestMessage()
-	msg.set_element_Ns2SplitRequestBody(
-		pack_soap(msg, "Ns2SplitRequestBody", req))
-
-	try:
-	    resp = port.Ns2Split(msg)
-	except ZSI.ParseException, e:
-	    raise service_error(service_error.req,
-		    "Bad format message (XMLRPC??): %s" %
-		    str(e))
-	r = unpack_soap(resp)
+	r = self.call_Ns2Split(uri, req, self.cert_file, self.cert_pwd, 
+		self.trusted_certs)
+
 	if r.has_key('Ns2SplitResponseBody'):
 	    r = r['Ns2SplitResponseBody']
@@ -965,8 +892,8 @@
 		return r['output'].splitlines()
 	    else:
-		raise service_error(service_error.proxy, 
+		raise service_error(service_error.protocol, 
 			"Bad splitter response (no output)")
 	else:
-	    raise service_error(service_error.proxy, "Bad splitter response")
+	    raise service_error(service_error.protocol, "Bad splitter response")
 	
     class current_testbed:
