ó ó÷Kc@sadZddlmZddlTddlmZddlmZddlm Z ddl m Z ddl m Z mZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ee'ƒZ(ddfZ)dfd„ƒYZ*de fd„ƒYZ+dS(s* Provides classes for (WS) SOAP bindings. iÿÿÿÿ(t getLogger(t*(t Namespace(tParser(tDocument(tElement(tFactorytObject(tContent(tLiteral(tBasic(tTyped(tMultiRef(t TypeQueryt ElementQuery(tOptions(tPluginContainer(tdeepcopysSOAP-ENVs)http://schemas.xmlsoap.org/soap/envelope/tBindingcBsïeZdZd„Zd„Zd„Zd„Zed„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„Zed„Zd„ZRS(sÀ The soap binding class used to process outgoing and imcoming soap messages per the WSDL port binding. @cvar replyfilter: The reply filter function. @type replyfilter: (lambda s,r: r) @ivar wsdl: The wsdl. @type wsdl: L{suds.wsdl.Definitions} @ivar schema: The collective schema contained within the wsdl. @type schema: L{xsd.schema.Schema} @ivar options: A dictionary options. @type options: L{Options} cCs|S(N((tstr((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt:scCs||_tƒ|_dS(sN @param wsdl: A wsdl. @type wsdl: L{wsdl.Definitions} N(twsdlR tmultiref(tselfR((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt__init__<s cCs |jjS(N(Rtschema(R((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRDscCs |jjS(N(Rtoptions(R((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRGscCs!|rt|jƒƒStƒSdS(s† Get the appropriate XML decoder. @return: Either the (basic|typed) unmarshaller. @rtype: L{UmxTyped} N(tUmxTypedRtUmxBasic(Rttyped((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt unmarshallerJscCst|jƒ|jƒjƒS(s| Get the appropriate XML encoder. @return: An L{MxLiteral} marshaller. @rtype: L{MxLiteral} (t MxLiteralRRtxstq(R((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt marshallerUscCs td‚dS(s Get parameter definitions. Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject}) @param method: A servic emethod. @type method: I{service.Method} @return: A collection of parameter definitions @rtype: [I{pdef},..] snot implementedN(t Exception(Rtmethod((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt param_defs]s cCsŽ|j|ƒ}|j|ƒ}|j|||ƒ}|j|ƒ}|j||ƒ}|jƒjrz|jƒ|jƒn |j ƒt |ƒS(së Get the soap message for the specified method, args and soapheaders. This is the entry point for creating the outbound soap message. @param method: The method being invoked. @type method: I{service.Method} @param args: A list of args for the method invoked. @type args: list @param kwargs: Named (keyword) args for the method invoked. @type kwargs: dict @return: The soap envelope. @rtype: L{Document} ( t headercontenttheadert bodycontenttbodytenvelopeRtprefixestnormalizePrefixestpromotePrefixest refitPrefixesR(RR$targstkwargstcontentR'R)tenv((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt get_messagehs   c Cs…|j|ƒ}tƒ}|jd|ƒ}t|jƒjƒ}|jjd|ƒ|jdƒ}|j ƒ|jdƒ}|j |ƒ|j j |ƒ}|j ||ƒ}|j|ƒ} t| ƒdkrè|j| |ƒ} || fSt| ƒdkr{| djƒr*|j| d|ƒ} || fSt|ƒr{|jƒ} | djdtƒ} | j |d| ƒ} || fSn|dfS( s> Process the I{reply} for the specified I{method} by sax parsing the I{reply} and then unmarshalling into python object(s). @param method: The name of the invoked method. @type method: str @param reply: The reply XML received after invoking the specified method. @type reply: str @return: The unmarshalled reply. The returned value is an L{Object} for a I{list} depending on whether the service returns a single object or a collection. @rtype: tuple ( L{Element}, L{Object} ) tstringtreplytEnvelopetBodyiit nobuiltinN(t replyfilterRtparseRRtpluginstmessagetparsedtgetChildR-t detect_faultRtprocesst replycontenttreturned_typestlentreplycompositet unboundedt replylistRtresolvetTruetNone( RR$R5tsaxt replyrootR;tsoapenvtsoapbodytnodestrtypestresultRtresolved((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt get_reply‚s2         cCse|jdtƒ}|dkr"dS|jtƒ}|j|ƒ}|jƒjrat||ƒ‚n|S(s» Detect I{hidden} soapenv:Fault element in the soap body. @param body: The soap envelope body. @type body: L{Element} @raise WebFault: When found. tFaultN( R>tenvnsRIRtFalseR@RtfaultstWebFault(RR)tfaultRtp((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR?©s cCsXg}|jdtƒ}|jƒ}x-|D]%}|j||ƒ}|j|ƒq+W|S(s‚ Construct a I{list} reply. This mehod is called when it has been detected that the reply is a list. @param rt: The return I{type}. @type rt: L{suds.xsd.sxbase.SchemaObject} @param nodes: A collection of XML nodes. @type nodes: [L{Element},...] @return: A list of I{unmarshalled} objects. @rtype: [L{Object},...] R8(RGRHRR@tappend(RtrtRNRPRQRtnodetsobject((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRFºs   c Cshi}x|D]}|||j not mapped to message partR8N(tnameRRtobjecttgetRIR#RGRHR@tgetattrREtsetattrRZt isinstancetlist( RRORNt dictionaryR[Rt compositeR\ttagRQR]tvalue((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRDÍs4         c Cs£|j|ƒ}tƒ}|jd|ƒ}|jdƒ}|jdƒ}|jdƒ}|jtƒ}|j|ƒ}|jƒjr–t ||ƒ‚n||j fS(s’ Extract the fault from the specified soap reply. If I{faults} is True, an exception is raised. Otherwise, the I{unmarshalled} fault L{Object} is returned. This method is called when the server raises a I{web fault}. @param reply: A soap reply message. @type reply: str @return: A fault object. @rtype: tuple ( L{Element}, L{Object} ) R4R6R7RS( R9RR:R>RRUR@RRVRWtdetail( RR5RJt faultrootRLRMRXRRY((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyt get_faultös  c CsL|jƒ}td|dd|d|dd|djƒƒ}|j|ƒS(sÈ Builds a parameter for the specified I{method} using the parameter definition (pdef) and the specified value (object). @param method: A method name. @type method: str @param pdef: A parameter definition. @type pdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject}) @param object: The parameter value. @type object: any @return: The parameter fragment. @rtype: L{Element} RhiRittypeitreal(R"RRGR@(RR$tpdefR`R"R1((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pytmkparam s  cCsˆ|jƒ}t|ttfƒrXg}x*|D]"}|j|j|||ƒƒq.W|Std|dd|d|dƒ}|j|ƒS(sÀ Builds a soapheader for the specified I{method} using the header definition (hdef) and the specified value (object). @param method: A method name. @type method: str @param hdef: A header definition. @type hdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject}) @param object: The header value. @type object: any @return: The parameter fragment. @rtype: L{Element} RhiRiRmi(R"RdRettupleRZtmkheaderRR@(RR$thdefR`R"ttagstitemR1((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRr!s   #cCsNtddtƒ}|jtjdtjdƒ|j|ƒ|j|ƒ|S(sH Build the B{} for an soap outbound message. @param header: The soap message B{header}. @type header: L{Element} @param body: The soap message B{body}. @type body: L{Element} @return: The soap envelope containing the body and header. @rtype: L{Element} R6tnsii(RRTt addPrefixRtxsinsRZ(RR'R)R2((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR*7s   cCs#tddtƒ}|j|ƒ|S(sÖ Build the B{} for an soap outbound message. @param content: The header content. @type content: L{Element} @return: the soap body fragment. @rtype: L{Element} tHeaderRv(RRTRZ(RR1R'((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR'Gs cCs td‚dS(sƒ Get the content for the soap I{body} node. @param method: A service method. @type method: I{service.Method} @param args: method parameter values @type args: list @param kwargs: Named (keyword) args for the method invoked. @type kwargs: dict @return: The xml content for the @rtype: [L{Element},..] snot implementedN(R#(RR$R/R0((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR(Ss c Csâd}g}|jƒj}|dk r=|j|jƒƒn|jƒj}t|ttt fƒsp|f}nt |ƒdkr†|S|j |ƒ}t|ttfƒr[x1|D]£}t|t ƒrß|jt |ƒƒq±nt |ƒ|krõPn|j||||ƒ}||djdƒ} |j| d| dƒ|j|ƒ|d7}q±Wnƒx€|D]x} |j| dƒ}|dkrqbn|j|| |ƒ}| djdƒ} |j| d| dƒ|j|ƒqbW|S(sà Get the content for the soap I{Header} node. @param method: A service method. @type method: I{service.Method} @return: The xml content for the @rtype: [L{Element},..] iitns0N(RtwsseRIRZtxmlt soapheadersRdRqRetdictRCtheadpart_typesRRRrt namespacet setPrefixRa( RR$tnR1R{theaderstptsR'thRvtpt((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR&as@      cCs td‚dS(s Get the reply body content. @param method: A service method. @type method: I{service.Method} @param body: The soap body @type body: L{Element} @return: the body content @rtype: [L{Element},...] snot implementedN(R#(RR$R)((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRAŠs cCs#tddtƒ}|j|ƒ|S(sÔ Build the B{} for an soap outbound message. @param content: The body content. @type content: L{Element} @return: the soap body fragment. @rtype: L{Element} R7Rv(RRTRZ(RR1R)((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR)–s cCs#g}|r!|jjjj}n|jjjj}xé|D]á}|jdk rat|jƒ}nt|j ƒ}|j |j ƒƒ}|dkr£t |j ƒ‚n|j dk rÇt|j|ƒ}n|r|jdkrõ|j|j|fƒq|j|j|fƒq:|j|ƒq:W|S(s– Get a list of I{parameter definitions} (pdef) defined for the specified method. Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject}) @param method: A service method. @type method: I{service.Method} @param input: Defines input/output message. @type input: boolean @return: A list of parameter definitions @rtype: [I{pdef},] N(tsoaptinputR)tpartstoutputtelementRIRR RmtexecuteRt TypeNotFoundtreft PartElementR_RZ(RR$RˆRPR‰RYtqueryR†((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pytbodypart_types¢s&   c Cs&g}|r|jjj}n|jjj}xò|D]ê}|j}|jdk rdt|jƒ}nt|j ƒ}|j |j ƒƒ}|dkr¦t |j ƒ‚n|j dk rÊt|j|ƒ}n|r|jdkrø|j|j|fƒq|j|j|fƒq4|j|ƒq4W|S(s– Get a list of I{parameter definitions} (pdef) defined for the specified method. Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject}) @param method: A service method. @type method: I{service.Method} @param input: Defines input/output message. @type input: boolean @return: A list of parameter definitions @rtype: [I{pdef},] N(R‡RˆRƒRŠtpartR‹RIRR RmRŒRRRŽRR_RZ( RR$RˆRPRƒR'R’RR†((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRÅs(    cCs7g}x*|j|dtƒD]}|j|ƒqW|S(sú Get the L{xsd.sxbase.SchemaObject} returned by the I{method}. @param method: A service method. @type method: I{service.Method} @return: The name of the type return by the method. @rtype: [I{rtype},..] Rˆ(R‘RURZ(RR$RPR[((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRBés(t__name__t __module__t__doc__R9RRRRHRR"R%R3RRR?RFRDRlRpRrR*R'R(R&RAR)R‘RRB(((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR,s2        '   )      ) # $RcBsAeZdZd„Zd„Zd„Zdd„Zed„Z RS(sÖ A part used to represent a message part when the part references a schema type and thus assumes to be an element. @ivar resolved: The part type. @type resolved: L{suds.xsd.sxbase.SchemaObject} cCsJtddtjƒ}tj||j|ƒ||_||_t|_ dS(s¥ @param name: The part name. @type name: str @param resolved: The part type. @type resolved: L{suds.xsd.sxbase.SchemaObject} R‹RvN( RRtxsdnst SchemaElementRRt_PartElement__resolvedR_RUtform_qualified(RR_RQtroot((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRÿs   cCs|S(N((R((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pytimplany scCstS(N(RH(R((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pytoptionalscCstjS(N(Rtdefault(Rtprefix((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR€scCs$|r|jjƒr|S|jSdS(N(R˜tbuiltin(RR8((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyRGsN( R“R”R•RR›RœRIR€RURG(((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyR÷s    N(,R•tloggingRtsudstsuds.saxRtsuds.sax.parserRtsuds.sax.documentRtsuds.sax.elementRtsuds.sudsobjectRRtsuds.mxRtsuds.mx.literalR R tsuds.umx.basicR Rtsuds.umx.typedR Rtsuds.bindings.multirefR tsuds.xsd.queryR Rtsuds.xsd.sxbasicR—t suds.optionsRt suds.pluginRtcopyRR“tlogRTRR(((s9/usr/lib/python2.7/site-packages/suds/bindings/binding.pyts,   ÿÌ