<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
I like this, too.&nbsp; It means that we don't have to smatter our code with
checking for a valid proxy cert, it'll just happen automatically with
each (failed) soap call.&nbsp; I think we really need to be able to isolate
it to authentication-related exceptions, though, since we don't want to
retry the call in the face of unrelated failures.<br>
<br>
<br>
Ivan R. Judson wrote:<br>
<blockquote type="cite" cite="mid200403082151.i28LpE9193670@mcs.anl.gov">
  <pre wrap="">
Looks cool; but I'm missing the motivation for it? Is something broken
without this?

--Ivan 

  </pre>
  <blockquote type="cite">
    <pre wrap="">-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:owner-ag-dev@mcs.anl.gov">owner-ag-dev@mcs.anl.gov</a> 
[<a class="moz-txt-link-freetext" href="mailto:owner-ag-dev@mcs.anl.gov">mailto:owner-ag-dev@mcs.anl.gov</a>] On Behalf Of Robert Olson
Sent: Monday, March 08, 2004 2:55 PM
To: <a class="moz-txt-link-abbreviated" href="mailto:ag-dev@mcs.anl.gov">ag-dev@mcs.anl.gov</a>
Subject: Fault handling redirects in SOAPpy

Try this on for size. In SOAPpy/CLient.py:

--- Client.py~  2004-02-17 22:05:59.000000000 -0600
+++ Client.py   2004-03-08 14:45:21.000000000 -0600
@@ -339,11 +339,46 @@
              header = hd, methodattrs = ma, encoding = self.encoding,
              config = self.config, noroot = self.noroot)

-        r, self.namespace = self.transport.call(self.proxy, 
m, ns, sa,
-                                                encoding = 
self.encoding,
-                                                http_proxy = 
self.http_proxy,
-                                                config = self.config)

+        call_retry = 0
+        try:
+
+            r, self.namespace = 
self.transport.call(self.proxy, m, ns, sa,
+                                                    encoding 
= self.encoding,
+                                                    http_proxy =
self.http_proxy,
+                                                    config = 
+ self.config)
+
+        except Exception, ex:
+            #
+            # Call failed.
+            #
+            # See if we have a fault handling vector installed in our
+            # config. If we do, invoke it. If it returns a 
true value,
+            # retry the call.
+            #
+            # In any circumstance other than the fault 
handler returning
+            # true, reraise the exception. This keeps the 
semantics of this
+            # code the same as without the fault_handler code.
+            #
+
+            if hasattr(self.config, "fault_handler"):
+                if callable(self.config.fault_handler):
+                    call_retry = 
self.config.fault_handler(self.proxy, ex)
+                    if not call_retry:
+                        raise
+                else:
+                    raise
+            else:
+                raise
+
+        if call_retry:
+            r, self.namespace = 
self.transport.call(self.proxy, m, ns, sa,
+                                                    encoding 
= self.encoding,
+                                                    http_proxy =
self.http_proxy,
+                                                    config = 
+ self.config)
+
+
+        print r
          p, attrs = parseSOAPRPC(r, attrs = 1)

          try:

With this mod to hosting/SOAPpy/Client.py:

diff -u -r1.6 Client.py
--- Client.py   2 Mar 2004 19:12:47 -0000       1.6
+++ Client.py   8 Mar 2004 20:51:20 -0000
@@ -29,7 +29,7 @@
      A class that encapsulates a SOAP proxy.
      """
      def __init__(self, url, namespace = None, authCallback 
= None, debug = 0,
-                 config = None):
+                 config = None, faultHandler = None):
          """
          @param url: the url to the service
          @param namespace: the namespace for the service @@ 
-46,6 +46,7 @@
              self.config = config

          self.config.debug = debug
+        self.config.fault_handler = faultHandler
          self.url = url.replace("https", "httpg")
          self.proxy = None
          self.namespace = namespace

We can write:

def fh(proxy, ex):
    print "Fault handler invoked! proxy=%s exception=%s" % (proxy, ex)
    return 0

try:
   self.profile.capabilities = Client.Handle( self.nodeServiceUri,
                                   faultHandler = fh).
                                        GetProxy().GetCapabilities()


A non-stub fault handler would do something like query the 
local cert mgmt infrastructure, which can interact with the 
user, to create the right flavor of proxy if possible, and 
return 1 to have the soap level retry the call.

Thoughts?

--bob


    </pre>
  </blockquote>
  <pre wrap=""><!---->

  </pre>
</blockquote>
</body>
</html>