本文整理汇总了Python中suds.sax.element.Element.addPrefix方法的典型用法代码示例。如果您正苦于以下问题:Python Element.addPrefix方法的具体用法?Python Element.addPrefix怎么用?Python Element.addPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suds.sax.element.Element
的用法示例。
在下文中一共展示了Element.addPrefix方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xml
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import addPrefix [as 别名]
def xml(self):
"""
Get xml representation of the object.
@return: The root node.
@rtype: L{Element}
"""
root = Element('UsernameToken', ns=WSSE_NS)
for p, u in self.nsprefixes.items():
root.addPrefix(p, u)
root.append(Attribute('wsu:Id', 'UsernameToken-9'))
root.append(Attribute('xmlns:wsu', WSU_URI))
u = Element('Username', ns=WSSE_NS)
u.setText(self.username)
root.append(u)
p = Element('Password', ns=WSSE_NS)
p.setText(self.password)
p.append(Attribute('Type', WSU_UN_URI))
root.append(p)
if self.nonce is not None:
n = Element('Nonce', ns=WSSE_NS)
n.setText(self.nonce)
root.append(n)
if self.created is not None:
n = Element('Created', ns=WSU_NS)
n.setText(str(UTC(self.created)))
root.append(n)
return root
示例2: node
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import addPrefix [as 别名]
def node(self, content):
ns = content.type.namespace()
if content.type.form_qualified:
node = Element(content.tag, ns=ns)
node.addPrefix(ns[0], ns[1])
else:
node = Element(content.tag)
self.encode(node, content)
log.debug('created - node:\n%s', node)
return node
示例3: node
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import addPrefix [as 别名]
def node(self, content):
#
# Create an XML node and namespace qualify as defined
# by the schema (elementFormDefault).
#
ns = content.type.namespace()
if content.type.form_qualified:
node = Element(content.tag, ns=ns)
node.addPrefix(ns[0], ns[1])
else:
node = Element(content.tag)
self.encode(node, content)
log.debug('created - node:\n%s', node)
return node
示例4: envelope
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import addPrefix [as 别名]
def envelope(self, header, body):
"""
Build the B{<Envelope/>} 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}
"""
env = Element('Envelope', ns=envns)
env.addPrefix(Namespace.xsins[0], Namespace.xsins[1])
env.append(header)
env.append(body)
return env
示例5: node
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import addPrefix [as 别名]
def node(self, content):
"""
Create an XML node.
The XML node is namespace qualified as defined by the corresponding
schema element.
"""
ns = content.type.namespace()
if content.type.form_qualified:
node = Element(content.tag, ns=ns)
if ns[0]:
node.addPrefix(ns[0], ns[1])
else:
node = Element(content.tag)
self.encode(node, content)
log.debug("created - node:\n%s", node)
return node
示例6: _build_security_header
# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import addPrefix [as 别名]
def _build_security_header(self, username, password):
""" Alternative method for building security header elements to use
in the SOAP calls. This method is *not* being used currently, but
is left here for reference.
"""
usernameElement = Element('Username', ns=WSSE_NS)
usernameElement.setText(username)
passwordElement = Element('Password', ns=WSSE_NS)
passwordElement.setText(password)
passwordElement.append(Attribute('Type', WSU_UN_URI))
userCreds = Element('UsernameToken', ns=WSSE_NS)
userCreds.append(Attribute('wsu:Id', 'UsernameToken-9'))
userCreds.append(Attribute('xmlns:wsu', WSSE_URI))
userCreds.insert(usernameElement)
userCreds.insert(passwordElement)
security = Element('Security', ns=WSSE_NS)
security.addPrefix(p='SOAP-ENC', u=SOAP_ENC_URI)
security.append(Attribute('SOAP-ENV:mustUnderstand', '1'))
security.append(Attribute('xmlns:wsse', WSSE_URI))
security.insert(userCreds)
return security