本文整理汇总了Python中suds.sax.element.Element类的典型用法代码示例。如果您正苦于以下问题:Python Element类的具体用法?Python Element怎么用?Python Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(self):
items = self.adsm_lists.service.GetListItems(self.args.list, self.args.view).listitems.data.row
method_idx = 1
batch = Element('Batch')\
.append(Attribute('OnError', 'Continue'))\
.append(Attribute('ListVersion', 1))
def update(b):
if not self.args.d:
updates = Element('ns1:updates').append(b)
print self.adsm_lists.service.UpdateListItems(listName=self.args.list, updates=updates)
for item in items:
method = Element('Method')\
.append(Attribute('ID', method_idx))\
.append(Attribute('Cmd', 'Delete'))\
.append(Element('Field')\
.append(Attribute('Name', 'ID'))\
.setText(item['_ows_ID']))
batch.append(method)
print method
method_idx += 1
if len(batch) > 20:
update(batch)
batch.detachChildren()
if len(batch) > 0:
update(batch)
示例2: init_client
def init_client(faults=True):
ENTREPRISE_WSDL = getattr(settings, 'SALESFORCE_ENTERPRISE_WSDL')
DJANGO_WSDL = getattr(settings, 'SALESFORCE_DJANGO_WSDL')
SALESFORCE_ENDPOINT = getattr(settings, 'SALESFORCE_ENDPOINT')
SALESFORCE_USER = getattr(settings, 'SALESFORCE_USER')
SALESFORCE_PASS = getattr(settings, 'SALESFORCE_PASS')
SALESFORCE_TOKEN = getattr(settings, 'SALESFORCE_TOKEN')
# Use the entreprise login to get a session id
entreprise_client = Client(ENTREPRISE_WSDL)
#entreprise_client.wsdl.url = SALESFORCE_ENDPOINT
login_result = entreprise_client.service.login(SALESFORCE_USER,
SALESFORCE_PASS+SALESFORCE_TOKEN)
# our client specific methods are in this specific
# NOTE we have to create the endpoint url using values from the serverUrl in the loginResponse plus
# the djangoAdapter schema
options = urlparse(login_result.serverUrl)
#DJANGO_SF_ENDPOINT = '%s://%s/services/Soap/class/dJangoAdapter' % (options.scheme, options.netloc)
django_client = Client(DJANGO_WSDL, location = SALESFORCE_ENDPOINT, faults=faults)
session_name_space = ('djan', 'http://soap.sforce.com/schemas/class/dJangoAdapter')
session = Element('sessionId').setText(login_result.sessionId)
wrapper = Element('SessionHeader')
wrapper.append(session)
django_client.set_options(soapheaders=wrapper)
return django_client
示例3: set_auth_header
def set_auth_header(self):
"""Set up the authorization header"""
auth_user = Element("username").setText(self.api_user)
auth_key = Element("apiKey").setText(self.api_key)
auth_header = Element("authenticate", ns=self.ims_ns)
auth_header.children = [auth_user, auth_key]
return auth_header
示例4: encryptMessage
def encryptMessage(self, env, use_encrypted_header=False, second_pass=False):
encrypted_parts = second_pass and self.second_pass_encrypted_parts or self.encrypted_parts
elements_to_encrypt = []
encrypted_headers = []
for elements_to_encrypt_func in encrypted_parts:
addl_elements = elements_to_encrypt_func(env)
if addl_elements[0] is None:
continue
if not isinstance(addl_elements[0], list):
addl_elements = ([addl_elements[0]], addl_elements[1])
for element in addl_elements[0]:
if element not in elements_to_encrypt:
if element[0].parent.match("Header") and use_encrypted_header:
enc_hdr = Element("EncryptedHeader", ns=wsse11ns)
element[0].parent.replaceChild(element[0], enc_hdr)
enc_hdr.append(element[0])
elements_to_encrypt.append((enc_hdr, "Content"))
encrypted_headers.append(enc_hdr)
else:
elements_to_encrypt.append((element, addl_elements[1]))
ref_list = xmlsec.encryptMessage(
self.cert, self.symmetricKey, elements_to_encrypt, "#" + self.keyId, self.keyReference, self.keyTransport
)
for enc_hdr in encrypted_headers:
enc_hdr.set("wsu:Id", enc_hdr[0].get("Id"))
enc_hdr[0].unset("Id")
if self.includeRefList:
self.encryptedKey.append(ref_list)
return self.encryptedKey
else:
return (self.encryptedKey, ref_list)
示例5: testWSDL
def testWSDL(wsdlURL):
replyURL = 'http://wsamplification.appspot.com/?webservice=' + wsdlURL
try:
client = Client(wsdlURL)
wsans = ('wsa', 'http://schemas.xmlsoap.org/ws/2004/08/addressing')
wsaReply = Element('ReplyTo', ns=wsans)
wsaAddress = Element('Address', ns=wsans).setText(replyURL)
wsaReply.insert(wsaAddress)
except:
print 'Moving on...'
return
try:
client.set_options(soapheaders=wsaReply)
#impl = getattr(client.service, 'submitOrderNoAck')
#print impl()
for method in client.wsdl.services[0].ports[0].methods.values():
print method.name
result = getattr(client.service, method.name)()
#print result()
except suds.WebFault as detail:
print 'Invoking method failed'
print client
except:
print 'Derping...'
print client
示例6: marshalled
def marshalled(self, context):
userid = self.userid
timestamp = rfc3339(datetime.datetime.now())
secret = self.secret
signature = sign(secret, timestamp+userid)
auth = self.authfragment % locals()
envelope = context.envelope
#Set the right ns prefixes
envelope.nsprefixes[ 'ns1' ] = envelope.nsprefixes[ 'ns0' ]
envelope.clearPrefix( 'ns0' )
#Add our auth to the header element
header = envelope.getChild('Header')
authns = Element( 'ns1:AuthenticationHeader' )
authns.append( Element( 'mktowsUserId' ).setText(self.userid) )
authns.append( Element( 'requestSignature' ).setText(signature) )
authns.append( Element( 'requestTimestamp' ).setText(timestamp) )
header.append( authns )
#Set the proper body prefixes
body = envelope.getChild( 'Body' )
body.prefix = 'SOAP-ENV'
body.children[0].prefix = 'ns1'
if self.debug:
with open("/tmp/envelope.txt","w") as f: f.write(envelope.str())
示例7: set_object_mask
def set_object_mask(self, data):
"""Create an object mask to tell the API what we want"""
print "%sObjectMask" % self.object_type
el = Element("%sObjectMask" % self.object_type, ns=self.ims_ns)
mask = Element("mask")
mask = self.build_soap_header(mask, data)
el.children = [mask]
return el
示例8: to_xml
def to_xml(self, factory):
# Needs to be an xsd:int with an attribute
# Can't do that with factory.create('ns0:quantity')
#metadata = factory.resolver.find('ns0:quantity')
#ns = metadata.namespace()
element = Element('ns0:quantity')
element.setText(str(self.value))
element.set('unitOfMeasure', self.unit)
return element
示例9: node
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
示例10: xml
def xml(self):
"""
Get xml representation of the object.
@return: The root node.
@rtype: L{Element}
"""
root = Element('Security', ns=wssens)
root.set('mustUnderstand', str(self.mustUnderstand).lower())
for t in self.tokens:
root.append(t.xml())
return root
示例11: header
def header(self, content):
"""
Build the B{<Body/>} for an soap outbound message.
@param content: The header content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}
"""
header = Element('Header', ns=envns)
header.append(content)
return header
示例12: body
def body(self, content):
"""
Build the B{<Body/>} for an soap outbound message.
@param content: The body content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}
"""
body = Element('Body', ns=envns)
body.append(content)
return body
示例13: connect
def connect(self):
from .client import SmsClient
from suds.sax.element import Element
self.client = SmsClient(self._vim.server_fqdn)
session = eval(list(self._vim.client.client.options.transport.cookiejar)[0].value)
cookie = Element("vcSessionCookie")
cookie.setText(session)
self.client.wsdl.options.__pts__.set("soapheaders", cookie)
ref = Property('ServiceInstance')
ref._type = 'ServiceInstance'
self.service_instance = SmsServiceInstance(self, name='ServiceInstance', ref=ref)
self.connected = True
示例14: set_session
def set_session(self, session_id):
"""
Record the session info.
"""
self.session = session_id
self.session_expiration = datetime.now() + timedelta(
seconds=self.session_duration)
session_namespace = ('ns1', 'http://api.zuora.com/')
session = Element('session', ns=session_namespace).setText(session_id)
header = Element('SessionHeader', ns=session_namespace)
header.append(session)
self.client.set_options(soapheaders=[header])
示例15: startElement
def startElement(self, name, attrs):
top = self.top()
node = Element(unicode(name), parent=top)
for a in attrs.getNames():
n = unicode(a)
v = unicode(attrs.getValue(a))
attribute = Attribute(n,v)
if self.mapPrefix(node, attribute):
continue
node.append(attribute)
top.append(node)
self.push(node)