def _Dispatch(ps, modules, SendResponse, SendFault, nsdict={}, typesmodule=None, <EOL>gettypecode=gettypecode, rpc=False, docstyle=False, **kw):
global _client_binding<EOL>try:<EOL><INDENT>what = str(ps.body_root.localName)<EOL>if modules is None:<EOL><INDENT>modules = ( sys.modules['<STR_LIT:__main__>'], )<EOL><DEDENT>handlers = [ getattr(m, what) for m in modules if hasattr(m, what) ]<EOL>if len(handlers) == <NUM_LIT:0>:<EOL><INDENT>raise TypeError("<STR_LIT>" + what)<EOL><DEDENT>handlers = [ h for h in handlers if callable(h) ]<EOL>if len(handlers) == <NUM_LIT:0>:<EOL><INDENT>raise TypeError("<STR_LIT>" + what)<EOL><DEDENT>if len(handlers) > <NUM_LIT:1>:<EOL><INDENT>raise TypeError("<STR_LIT>" + repr(handlers))<EOL><DEDENT>handler = handlers[<NUM_LIT:0>]<EOL>_client_binding = ClientBinding(ps)<EOL>if docstyle:<EOL><INDENT>result = handler(ps.body_root)<EOL>tc = TC.XML(aslist=<NUM_LIT:1>, pname=what+'<STR_LIT>')<EOL><DEDENT>elif not rpc:<EOL><INDENT>try:<EOL><INDENT>tc = gettypecode(typesmodule, ps.body_root)<EOL><DEDENT>except Exception:<EOL><INDENT>tc = TC.Any()<EOL><DEDENT>try:<EOL><INDENT>arg = tc.parse(ps.body_root, ps)<EOL><DEDENT>except EvaluateException as ex:<EOL><INDENT>SendFault(FaultFromZSIException(ex), **kw)<EOL>return<EOL><DEDENT>try:<EOL><INDENT>result = handler(arg)<EOL><DEDENT>except Exception as ex:<EOL><INDENT>SendFault(FaultFromZSIException(ex), **kw)<EOL>return<EOL><DEDENT>try:<EOL><INDENT>tc = result.typecode<EOL><DEDENT>except AttributeError as ex:<EOL><INDENT>SendFault(FaultFromZSIException(ex), **kw)<EOL>return<EOL><DEDENT><DEDENT>elif typesmodule is not None:<EOL><INDENT>kwargs = {}<EOL>for e in _child_elements(ps.body_root):<EOL><INDENT>try:<EOL><INDENT>tc = gettypecode(typesmodule, e)<EOL><DEDENT>except Exception:<EOL><INDENT>tc = TC.Any()<EOL><DEDENT>try:<EOL><INDENT>kwargs[str(e.localName)] = tc.parse(e, ps)<EOL><DEDENT>except EvaluateException as ex:<EOL><INDENT>SendFault(FaultFromZSIException(ex), **kw)<EOL>return<EOL><DEDENT><DEDENT>result = handler(**kwargs)<EOL>aslist = False<EOL>if type(result) in _seqtypes:<EOL><INDENT>for o in result:<EOL><INDENT>aslist = hasattr(result, '<STR_LIT>')<EOL>if aslist: break<EOL><DEDENT><DEDENT>elif type(result) is not dict:<EOL><INDENT>aslist = not hasattr(result, '<STR_LIT>')<EOL>result = (result,)<EOL><DEDENT>tc = TC.Any(pname=what+'<STR_LIT>', aslist=aslist)<EOL><DEDENT>else:<EOL><INDENT>tp = _find_type(ps.body_root)<EOL>isarray = ((type(tp) in (tuple,list) and tp[<NUM_LIT:1>] == '<STR_LIT>') or _find_arraytype(ps.body_root))<EOL>data = _child_elements(ps.body_root)<EOL>tc = TC.Any()<EOL>if isarray and len(data) == <NUM_LIT:0>:<EOL><INDENT>result = handler()<EOL><DEDENT>elif isarray:<EOL><INDENT>try: arg = [ tc.parse(e, ps) for e in data ]<EOL>except EvaluateException as e:<EOL><INDENT>SendFault(RuntimeError("<STR_LIT>" %isarray))<EOL>return<EOL><DEDENT>result = handler(*arg)<EOL><DEDENT>else:<EOL><INDENT>try: kwarg = dict([ (str(e.localName),tc.parse(e, ps)) for e in data ])<EOL>except EvaluateException as e:<EOL><INDENT>SendFault(FaultFromZSIException(e), **kw)<EOL>return<EOL><DEDENT>result = handler(**kwarg)<EOL><DEDENT>tc = TC.Any(pname=what+'<STR_LIT>')<EOL><DEDENT>sw = SoapWriter(nsdict=nsdict)<EOL>sw.serialize(result, tc)<EOL>return SendResponse(str(sw), **kw)<EOL><DEDENT>except Fault as e:<EOL><INDENT>return SendFault(e, **kw)<EOL><DEDENT>except Exception as e:<EOL><INDENT>return SendFault(FaultFromException(e, <NUM_LIT:0>, sys.exc_info()[<NUM_LIT:2>]), **kw)<EOL><DEDENT>
Find a handler for the SOAP request in ps; search modules.
    Call SendResponse or SendFault to send the reply back, appropriately.

    Behaviors:
        default -- Call "handler" method with pyobj representation of body root, and return
            a self-describing request (w/typecode).  Parsing done via a typecode from 
            typesmodule, or Any.

        docstyle -- Call "handler" method with ParsedSoap instance and parse result with an
          XML typecode (DOM). Behavior, wrap result in a body_root "Response" appended message.

        rpc -- Specify RPC wrapper of result. Behavior, ignore body root (RPC Wrapper)
           of request, parse all "parts" of message via individual typecodes.  Expect
           the handler to return the parts of the message, whether it is a dict, single instance, 
           or a list try to serialize it as a Struct but if this is not possible put it in an Array.
           Parsing done via a typecode from typesmodule, or Any.