本文整理汇总了Python中suds.client.Client.last_sent方法的典型用法代码示例。如果您正苦于以下问题:Python Client.last_sent方法的具体用法?Python Client.last_sent怎么用?Python Client.last_sent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suds.client.Client
的用法示例。
在下文中一共展示了Client.last_sent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: timbrar
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
def timbrar(self, src, opciones = { 'generarCBB': False, 'generarTXT': False, 'generarPDF': False}):
try:
# en caso de que src sea una ruta a archivo y no una cadena, abrir y cargar ruta
if os.path.isfile(src): src = open(src, 'r').read()
opciones['text2CFDI'] = base64.b64encode(src)
self.opciones.update(opciones)
cliente = Client(self.url)
respuesta = cliente.service.requestTimbrarCFDI(self.opciones)
for propiedad in ['xml', 'pdf', 'png', 'txt']:
if propiedad in respuesta:
self.__dict__[propiedad] = base64.b64decode(respuesta[propiedad])
if 'xml' in respuesta:
xml_cfdi = ET.fromstring(self.xml)
tfd = xml_cfdi.xpath('//tfd:TimbreFiscalDigital', namespaces={"tfd": "http://www.sat.gob.mx/TimbreFiscalDigital"})
self.__dict__['uuid'] = tfd[0].get('UUID')
if self.debug:
self.logger.info("\nSOAP request:\n %s" % cliente.last_sent())
self.logger.info("\nSOAP response:\n %s" % cliente.last_received())
return True
except WebFault, e:
self.__dict__['codigo_error'] = e.fault.faultcode
self.__dict__['error'] = e.fault.faultstring
if self.debug:
self.logger.error("\nSOAP request:\n %s\nSOAP response: [%s] - %s" % (cliente.last_sent(), e.fault.faultcode, e.fault.faultstring))
return False
示例2: SudsClient
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
class SudsClient(object):
zope.interface.implements(ClientAdapter)
def __init__(self, wsdl, options={}):
if not 'plugins' in options:
options['plugins'] = [SoapEnvelopeNamespaceFix()]
else:
options['plugins'].append(SoapEnvelopeNamespaceFix())
# TODO: add headers for compression per provider/request
if not 'headers' in options:
options['headers'] = {}
options['headers'].update({"Accept-Encoding": "gzip"})
options['plugins'] = [SupportGZIPPlugin()]
self.client = Client(wsdl, **options)
self.client.connect()
def set_headers(self, headers):
self.client.set_options(soapheaders=headers)
def send_request(self, method_name, params):
return getattr(self.client.service, method_name)(**params)
def get_last_response(self):
return self.client.last_received()
def get_last_request(self):
return self.client.last_sent()
def new_context(self):
return SudsClientProxy(self)
示例3: cancelar
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
def cancelar(self, uuid):
try:
cliente = Client(self.url)
opciones = {'uuid': uuid}
opciones.update(self.opciones)
respuesta = cliente.service.requestCancelarCFDI(opciones)
if self.debug:
self.logger.info("\nSOAP request:\n %s" % cliente.last_sent())
self.logger.info("\nSOAP response:\n %s" % cliente.last_received())
return True
except WebFault, e:
self.__dict__['codigo_error'] = e.fault.faultcode
self.__dict__['error'] = e.fault.faultstring
if self.debug:
self.logger.error("\nSOAP request:\n %s\nSOAP response: [%s] - %s" % (cliente.last_sent(), e.fault.faultcode, e.fault.faultstring))
return False
示例4: __init__
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
class ManageSmsService:
def __init__(self, username, password, host = 'http://ws.smshosting.it'):
"""ManageSmsService( username, password, host = 'http://ws.smshosting.it')
Instantiates an instance of ManageSmsService.
Parameters:
username - Your SmsHosting.it username.
password - Your SmsHosting.it secret key.
host - Server address.
"""
self.username = username
self.password = password
if host.endswith('/'):
self.address = host + 'smsWebService/ManageSms?wsdl'
else:
self.address = host + '/smsWebService/ManageSms?wsdl'
# Check and set up authentication
if self.username is not None and self.password is not None:
# Assume Basic authentication ritual
self.client = Client(self.address)
else:
raise pySmsHostingError("Authentication failed with your provided credentials. Try again? (%s failure)" % `e.code`, e.code)
self.numbers = self.client.factory.create('sendPayLoad')
#print self.numbers
def setNumber(self, number, customerId = None):
phone = self.client.factory.create('msisdn')
phone.customerId = customerId
phone.number = number
self.numbers.numbers.append(phone)
return
def send(self, text, sender = "SMSHosting.it", dateTime = None, groups = None, transactionId = None ):
"""send(xs:string password, xs:string username, xs:string dateTime, xs:string from, xs:string[] groups, msisdn[] numbers, xs:string text, xs:string transactionId, )
"""
global errors
try:
result = self.client.service.send(self.password, self.username, dateTime, sender, groups, self.numbers.numbers, text, transactionId)
sent = self.client.last_sent()
rcvd = self.client.last_received()
#print '\nreply(\n%s\n)\n' % result
return result
except WebFault, f:
errors += 1
print f
print f.fault
except Exception, e:
errors += 1
print e
tb.print_exc()
示例5: SudsClient
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
class SudsClient(object):
zope.interface.implements(ClientAdapter)
def __init__(self, wsdl, options={}):
if 'headers' not in options:
options['headers'] = {}
if 'plugins' not in options:
options['plugins'] = []
options['headers'].update({'Accept-Encoding': 'gzip'})
options['plugins'].append(SupportGZIPPlugin())
self.client = Client(wsdl, **options)
self.client.connect()
def set_headers(self, headers):
self.client.set_options(soapheaders=headers)
def send_request(self, method_name, params):
return getattr(self.client.service, method_name)(**params)
def get_last_response(self):
return self.client.last_received()
def get_last_request(self):
return self.client.last_sent()
def new_context(self):
return SudsClientProxy(self)
示例6: gpn
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
class gpn(Client):
def __int__(self, username, password, url=None):
"""
@param username: The username for the service.
@type username: str
@param password: The password for the service.
@type password: str
@param password: The password for the service.
@type password: str
@param url: The WSDL url for the service.
@type url: str
"""
self.username = username
self.password = password
self.url = url
def __str__(self):
return '[user: %s\tpassword: %s\twsdl: %s]' % (self.username,
self.password,
self.url)
def service(self, transport=None):
"""
The B{service} selector is used to select a web service.
In most cases, the wsdl only defines (1) service in which access
by subscript is passed through to a L{PortSelector}. This is also the
behavior when a I{default} service has been specified. In cases
where multiple services have been defined and no default has been
specified, the service is found by name (or index) and a L{PortSelector}
for the service is returned. In all cases, attribute access is
forwarded to the L{PortSelector} for either the I{first} service or the
I{default} service (when specified).
@ivar __client: A suds client.
@type __client: L{Client}
@ivar __services: A list of I{wsdl} services.
@type __services: list
"""
self.soapclient = Client(self.url)
if transport:
self.soapclient = Client(self.url, transport=None)
return self.soapclient.service
def last_sent(self):
"""
Get last sent I{soap} message.
@return: The last sent I{soap} message.
@rtype: L{Document}
"""
return self.soapclient.last_sent()
def last_received(self):
"""
Get last received I{soap} message.
@return: The last received I{soap} message.
@rtype: L{Document}
"""
return self.soapclient.last_received()
示例7: pass_request_to_client_esb
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
def pass_request_to_client_esb(self):
# Request and response data
logged_request = json.loads(self.request_parameters)
logged_response = json.loads(self.response)
P_CRM_ID = logged_request.get("P_TRXN_NO")
P_CIRCUIT_NO = "17XXXXXX"
P_SERVICE_TYPE = "SaaS"
P_ACTION_TYPE = "00"
P_RETURN_CODE = logged_response.get("P_RETURN_CODE")
P_RETURN_MESG = logged_response.get("P_RETURN_MESG")
P_ATTRIBUTE1 = logged_request.get("P_ATTRIBUTE1") or None
P_ATTRIBUTE2 = logged_request.get("P_ATTRIBUTE2") or None
P_ATTRIBUTE3 = logged_request.get("P_ATTRIBUTE3") or None
try:
from suds.client import Client
#TODO check the URL for wsdl
url = "%s/assets/erpnext/CRM_ACCEPTANCE_MSGService.wsdl"%(frappe.utils.get_url())
# url = "http://localhost:9777/assets/erpnext/CRM_ACCEPTANCE_MSGService.wsdl"
print frappe.utils.get_url(), "URL", url
# url = "http://84.255.152.200:9777/assets/erpnext/CRM_ACCEPTANCE_MSGService.wsdl"
client = Client(url, cache=None)
response = client.service.AcceptRequest(P_CRM_ID=P_CRM_ID,P_SERVICE_TYPE=P_SERVICE_TYPE,
P_CIRCUIT_NO=P_CIRCUIT_NO,P_ACTION_TYPE=P_ACTION_TYPE,
P_RETURN_CODE=P_RETURN_CODE,P_RETURN_MESG=P_RETURN_MESG,
P_ATTRIBUTE1=P_ATTRIBUTE1,P_ATTRIBUTE2=P_ATTRIBUTE2,
P_ATTRIBUTE3=P_ATTRIBUTE3)
self.esb_request = client.last_sent().str()
self.esb_response = str(response)
self.status = "Completed" if response.X_ERROR_CODE == "S" else "Not Completed"
print "Completed", str(response)
except Exception, e:
import traceback
# print traceback.format_exc()
self.status = "Not Completed"
self.error = str(traceback.format_exc())
self.esb_request = "<xmp>%s</xmp>"%client.last_sent().str()
示例8: activarCancelacion
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
def activarCancelacion(self, archCer, archKey, passKey):
try:
# en caso de que archCer y/o archKey sean una ruta a archivo y no una cadena, abrir y cargar ruta
if os.path.isfile(archCer): archCer = open(archCer, 'r').read()
if os.path.isfile(archKey): archKey = open(archKey, 'r').read()
opciones = {}
opciones['archivoKey'] = base64.b64encode(archKey)
opciones['archivoCer'] = base64.b64encode(archCer)
opciones['clave'] = passKey
self.opciones.update(opciones)
cliente = Client(self.url)
respuesta = cliente.service.activarCancelacion(self.opciones)
if self.debug:
self.logger.info("\nSOAP request:\n %s" % cliente.last_sent())
self.logger.info("\nSOAP response:\n %s" % cliente.last_received())
return True
except WebFault, e:
self.__dict__['codigo_error'] = e.fault.faultcode
self.__dict__['error'] = e.fault.faultstring
if self.debug:
self.logger.error("\nSOAP request:\n %s\nSOAP response: [%s] - %s" % (cliente.last_sent(), e.fault.faultcode, e.fault.faultstring))
return False
示例9: WsTest
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
def WsTest(url,Wsname,data):
'''
:param url: wsdl地址
:param Wsname: 方法名,做保存结果的文件名
:param data: 方法的传入参数
:return:
'''
client = Client(url)#创建一个webservice接口对象
# print client
client.service.getMobileCodeInfo(data)#调用这个接口下的getMobileCodeInfo方法,并传入参数
req = str(client.last_sent())#保存请求报文,因为返回的是一个实例,所以要转换成str
response = str(client.last_received())#保存返回报文,返回的也是一个实例
print response#打印返回报文
WriteRes(Wsname,req,response,data)#调用写入结果函数,把方法名、请求报文、返回报文、和入参传进去
示例10: WebService
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
class WebService(object):
def __init__(self, url, use_real_url, **kwargs):
self.use_real_url = use_real_url
self.suds_client = Client(url, timeout=180, **kwargs) # default suds transport timeout is 90 seconds
self.service_url = str(url.replace('?wsdl', '')) # to work around erp tunnel port not preserved bug
def new_object_of_type(self, wsdl_type, returns_dict_object=False):
suds_object = self.suds_client.factory.create(wsdl_type)
if returns_dict_object:
return DictObject(self.suds_client.dict(suds_object))
return suds_object
def last_sent(self):
return self.suds_client.last_sent()
def last_received(self):
return self.suds_client.last_received()
def __getattr__(self, item):
service = getattr(self.suds_client.service, item)
if not self.use_real_url:
service.method.location = self.service_url
return service
示例11: Client
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
#!/usr/bin/python
#Import modules to use
from suds.client import Client
#from SOAPpy import WSDL
from suds.sax.element import Element
from suds.sax.attribute import Attribute
import logging
import hashlib
import time
#Enable logging to be abale to see whats being sent and received back
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.basicConfig(filename="/tmp/sendSms.log", level=logging.INFO)
url = 'http://localhost/biller/server.php?wsdl'
client = Client(url, location='http://localhost/biller/server.php')
client.set_options(cache=None)
print client
client.service.billerValidate('MB', '23456', '1', 'Airtime', '0772744288','', '10000')
print client.last_sent()
print client.last_received()
示例12: SforceBaseClient
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
#.........这里部分代码省略.........
self._sforce.set_options(soapheaders = headers)
def setStrictResultTyping(self, strictResultTyping):
'''
Set whether single results from any of the following calls return the result wrapped in a list,
or simply the single result object:
convertLead()
create()
delete()
emptyRecycleBin()
invalidateSessions()
merge()
process()
retrieve()
undelete()
update()
upsert()
describeSObjects()
sendEmail()
'''
self._strictResultTyping = strictResultTyping
def getSessionId(self):
return self._sessionId
def getLocation(self):
return self._location
def getConnection(self):
return self._sforce
def getLastRequest(self):
return str(self._sforce.last_sent())
def getLastResponse(self):
return str(self._sforce.last_received())
def getLastResponseAsDocument(self):
return self._sforce.last_received()
def getDebugLog(self):
try:
return self.getLastResponseAsDocument().getChild("soapenv:Envelope").getChild("soapenv:Header").getChild("DebuggingInfo").getChild("debugLog").getText()
except:
return 'No debug log available'
def getMetadaServerUrl(self):
return str(self._metadataServerUrl)
def getUserId(self):
return str(self._userId)
# Core calls
def create(self, sObjects):
self._setHeaders('create')
return self._handleResultTyping(self._sforce.service.create(sObjects))
def getUpdated(self, sObjectType, startDate, endDate):
'''
Retrieves the list of individual objects that have been updated (added or
changed) within the given timespan for the specified object.
'''
self._setHeaders('getUpdated')
return self._sforce.service.getUpdated(sObjectType, startDate, endDate)
示例13: rhqTest
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
def rhqTest():
global errors
url = 'http://localhost.localdomain:7080/rhq-rhq-enterprise-server-ejb3/WebservicesManagerBean?wsdl'
start(url)
client = Client(url)
print client
try:
#
# create name
#
name = client.factory.create('name')
name.first = u'Jeff'+unichr(1234)
name.last = 'Ortel &lt; Company'
#
# create a phone object using the wsdl
#
phoneA = client.factory.create('phone')
phoneA.npa = 410
phoneA.nxx = 555
phoneA.number = 5138
phoneB = client.factory.create('phone')
phoneB.npa = 919
phoneB.nxx = 555
phoneB.number = 4406
#
# lets add some animals
#
dog = client.factory.create('dog')
dog.name = 'rover'
dog.age = 3
cat = client.factory.create('cat')
cat.name = 'kitty'
cat.age = 4
#
# create a person object using the wsdl
#
person = client.factory.create('person')
print person
person.name = name
person.age = 43
person.phone.append(phoneA)
person.phone.append(phoneB)
person.pet.append(dog)
person.pet.append(cat)
print person
#
# addPerson()
#
print 'addPersion()'
result = client.service.addPerson(person)
sent = client.last_sent()
rcvd = client.last_received()
print '\nreply(\n%s\n)\n' % result
#
# create a new name object used to update the person
#
newname = client.factory.create('name')
newname.first = 'Todd'
newname.last = None
#
# update the person's name (using the webservice)
#
print 'updatePersion()'
result = client.service.updatePerson(person, newname)
print '\nreply(\n%s\n)\n' % str(result)
result = client.service.updatePerson(person, None)
print '\nreply(\n%s\n)\n' % str(result)
except WebFault, f:
errors += 1
print f
print f.fault
示例14: rhqTest
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
def rhqTest():
global errors
url = "http://localhost.localdomain:7080/rhq-rhq-enterprise-server-ejb3/WebservicesManagerBean?wsdl"
start(url)
client = Client(url)
print client
try:
#
# create name
#
name = client.factory.create("name")
name.first = u"Jeff" + unichr(1234)
name.last = "Ortel &lt; Company"
#
# create a phone object using the wsdl
#
phoneA = client.factory.create("phone")
phoneA.npa = 410
phoneA.nxx = 555
phoneA.number = 5138
phoneB = client.factory.create("phone")
phoneB.npa = 919
phoneB.nxx = 555
phoneB.number = 4406
#
# lets add some animals
#
dog = client.factory.create("dog")
dog.name = "rover"
dog.age = 3
cat = client.factory.create("cat")
cat.name = "kitty"
cat.age = 4
#
# create a person object using the wsdl
#
person = client.factory.create("person")
print person
person.name = name
person.age = 43
person.phone.append(phoneA)
person.phone.append(phoneB)
person.pet.append(dog)
person.pet.append(cat)
print person
#
# addPerson()
#
print "addPersion()"
result = client.service.addPerson(person)
sent = client.last_sent()
rcvd = client.last_received()
print "\nreply(\n%s\n)\n" % result
#
# create a new name object used to update the person
#
newname = client.factory.create("name")
newname.first = "Todd"
newname.last = None
#
# update the person's name (using the webservice)
#
print "updatePersion()"
result = client.service.updatePerson(person, newname)
print "\nreply(\n%s\n)\n" % str(result)
result = client.service.updatePerson(person, None)
print "\nreply(\n%s\n)\n" % str(result)
except WebFault, f:
errors += 1
print f
print f.fault
示例15:
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import last_sent [as 别名]
#encoding:utf-8
from suds.client import Client
url="http://www.106818.com/ws/LinkWS.asmx?wsdl"
client=Client(url)
client.service.SelSum('SY0134','82342367')
req=str(client.last_sent())
print req
print "--------------------------------------------------"
response=str(client.last_received())
print response