本文整理汇总了Python中suds.client.Client.set_options方法的典型用法代码示例。如果您正苦于以下问题:Python Client.set_options方法的具体用法?Python Client.set_options怎么用?Python Client.set_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suds.client.Client
的用法示例。
在下文中一共展示了Client.set_options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SwisClient
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
class SwisClient(object):
def __init__(self, username=None, password=None):
self.wsdl = 'https://%s:17778/SolarWinds/InformationService/v3?wsdl' % CONF.solarwinds_host
LOG.debug('wsdl = %s', self.wsdl)
self.client = Client(self.wsdl, username=username, password=password)
self.client.set_options(port='BasicHttpBinding_InformationService')
LOG.debug('client = %s', self.client)
prog = os.path.basename(sys.argv[0])
self.cursor_file = '%s/%s.cursor' % (CONF.pid_dir, prog)
self.npm_event_id_cursor = None
self.ucs_event_id_cursor = None
if os.path.isfile(self.cursor_file):
try:
self.npm_event_id_cursor, self.ucs_event_id_cursor = open(self.cursor_file).read().splitlines()
LOG.info('Event IDs cursor read from file: %s, %s', self.npm_event_id_cursor, self.ucs_event_id_cursor)
except Exception, e:
LOG.error('Failed to read event IDs from cursor file: %s', e)
if not self.npm_event_id_cursor:
self.npm_event_id_cursor = self._get_max_npm_event_id()
LOG.info('NPM Event ID cursor queried from db: %s', self.npm_event_id_cursor)
if not self.ucs_event_id_cursor:
self.ucs_event_id_cursor = self._get_max_ucs_event_id()
LOG.info('UCS Event ID cursor queried from db: %s', self.ucs_event_id_cursor)
示例2: __init__
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
class JasperClient:
def __init__(self,url,username,password):
self.client = Client(url,username=username,password=password)
def listReports(self,dir=""):
req = createRequest(
uriString=dir,
wsType="folder",
operationName="list")
res = self.client.service.list(req)
return [rd.get('uriString') for rd in ET.fromstring(res).findall('resourceDescriptor') if rd.get('wsType') == 'reportUnit']
def runReport(self,uri,output="PDF",params={}):
""" uri should be report URI on JasperServer
output may be PDF, JRPRINT, HTML, XLS, XML, CSV and RTF; default PDF
but JRPRINT is useless, so don't use it
params may contain parameters as a simple dict for passing to the report
this method will return a dict containing 'content-type' and 'data'.
"""
self.client.set_options(retxml=True) # suds does not parse MIME encoded so we cancel it
req = createRequest(
arguments={"RUN_OUTPUT_FORMAT" : output},
uriString = uri,
wsType = "reportUnit",
operationName="runReport",
params=params)
res = self.client.service.runReport(req)
self.client.set_options(retxml=False) # temporarily of course
res = parseMultipart(res)
return res
示例3: get_fms_client
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def get_fms_client():
"""
Returns a soap client object.
If an object has already been created, we recyle it,
otherwise, a new one is created and returned.
"""
app = webapp2.get_app()
request = webapp2.get_request()
username = request.registry["session"].get("username")
password = request.registry["session"].get("password")
fms_key = "fms_client:{}".format(username)
# check if we already have the client
fms_client = app.registry.get(fms_key)
if not fms_client:
fms_client = Client(FMS_URL, cache=None)
fms_client.add_prefix("rsp", "http://response.atms.core.mtrak.digi.com/xsd")
fms_client.add_prefix("srv", "http://service.atms.core.mtrak.digi.com")
fms_client.add_prefix("vo", "http://vo.atms.core.mtrak.digi.com/xsd")
app.registry[fms_key] = fms_client
fms_client.set_options(soapheaders=(Element("username").setText(username), Element("password").setText(password)))
return fms_client
示例4: soap_login
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def soap_login(options):
run_delay(options)
if options.has_key("--ssl"):
url = "https://"
else:
url = "http://"
url += options["--ip"] + ":" + str(options["--ipport"]) + "/sdk"
tmp_dir = tempfile.mkdtemp()
tempfile.tempdir = tmp_dir
atexit.register(remove_tmp_dir, tmp_dir)
try:
conn = Client(url + "/vimService.wsdl")
conn.set_options(location = url)
mo_ServiceInstance = Property('ServiceInstance')
mo_ServiceInstance._type = 'ServiceInstance'
ServiceContent = conn.service.RetrieveServiceContent(mo_ServiceInstance)
mo_SessionManager = Property(ServiceContent.sessionManager.value)
mo_SessionManager._type = 'SessionManager'
conn.service.Login(mo_SessionManager, options["--username"], options["--password"])
except Exception:
fail(EC_LOGIN_DENIED)
options["ServiceContent"] = ServiceContent
options["mo_SessionManager"] = mo_SessionManager
return conn
示例5: get_client
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def get_client(url):
client = Client(url)
credentials = client.factory.create('credentials')
credentials.username = 'webmail'
credentials.password = 'webmail'
client.set_options(soapheaders=credentials)
return client
示例6: call_webservice
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def call_webservice(self, **kwargs):
"""Client Suds """
wsdl = kwargs.get('wsdl', '')
method = kwargs.get('method', '')
timeout = kwargs.get('timeout', DEFAULT_TIMEOUT)
proxy = kwargs.get('proxy', False)
http_proxy = kwargs.get('http_proxy', '')
parameters = kwargs.get('parameters')
if kwargs.get('ignore_ssl', ''):
ssl._create_default_https_context = ssl._create_unverified_context
imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
doctor = ImportDoctor(imp)
client = Client(wsdl, timeout=timeout, doctor=doctor)
if proxy:
http_proxy = os.environ.get('HTTP_PROXY', http_proxy)
client.set_options(proxy=http_proxy)
if isinstance(parameters, dict):
ws_value = getattr(client.service, method)(**parameters)
else:
if not isinstance(parameters, tuple):
parameters = (parameters,)
ws_value = getattr(client.service, method)(*parameters)
value = node_to_dict(ws_value, {})
if isinstance(value, dict) and len(value.keys()) == 1:
value = value[value.keys()[0]]
return value
示例7: MarketoClientFactory
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def MarketoClientFactory(ini, **kwargs):
import json
with open(ini) as f:
ini = json.loads(f.read())
for key, item in ini.items():
ini[key] = str(item)
ini.update(kwargs)
wsdl = ini["wsdl"]
cache = None
if '://' not in wsdl:
if os.path.isfile(wsdl):
wsdl = 'file://' + os.path.abspath(wsdl)
client = Client(wsdl, location=ini['endpoint'], cache=cache, plugins=[MarketoSignaturePlugin(ini["userid"],ini["encryption_key"])])
headers = {}
client.set_options(headers=headers)
if kwargs.has_key('proxy'):
if kwargs['proxy'].has_key('https'):
raise NotImplementedError('Connecting to a proxy over HTTPS not supported.')
client.set_options(proxy=kwargs['proxy'])
return client
示例8: get_lgn_client
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def get_lgn_client():
'''
Returns a soap client object.
If an object has already been created, we recyle it,
otherwise, a new one is created and returned.
'''
app = webapp2.get_app()
request = webapp2.get_request()
username = request.registry['session'].get('username')
password = request.registry['session'].get('password')
lgn_key = 'lgn_client:{}'.format(username)
# Check if we already have the client
lgn_client = app.registry.get(lgn_key)
if not lgn_client:
lgn_client = Client(LGN_URL, cache=None)
lgn_client.add_prefix(
'srv', "http://service.login.core.mtrak.digi.com")
lgn_client.add_prefix(
'vo', "http://vo.login.core.mtrak.digi.com/xsd")
app.registry[lgn_key] = lgn_client
lgn_client.set_options(soapheaders=(
Element('username').setText(username),
Element('password').setText(password)))
return lgn_client
示例9: createPayment
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def createPayment(self, amount, currency, cardNumber, expiryMonth, expiryYear, cardSecurityCode, scheme, orderId):
""" Main method, performs a createRequest payment
Keyword arguments:
amount -- the payment amount
currency -- the currency code (978 is for Euro)
cardNumber -- the credit card number
expiryMonth -- the month (MM) of the credit card expiry
expiryYear -- the year (YYYY) of the credit card expiry
cardSecurityCode -- the security code of the credit card
scheme -- the scheme of the credit card (ie 'VISA')
orderId -- the identifier of the order related to the requested payment
Returns:
SUDS answer
"""
self.logger.info("'createPayment' requested for order id {} (amount: {}, currency: {})".format(orderId, amount, currency))
# Create a SUDS client of the PayZen platform
client = Client(url=self.platform['wsdl'])
# Each request needs a timestamp
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
# SOAP headers construction and definition
headers = self.headers(timestamp)
client.set_options(soapheaders=headers)
# Builds the payload
## commonRequest part
commonRequest = {'submissionDate': timestamp}
## paymentRequest part
paymentRequest = {'amount': amount, 'currency': currency}
## orderRequest part
orderRequest = {'orderId': orderId}
## cardRequest part
cardRequest = {
'number': cardNumber
, 'expiryMonth': expiryMonth
, 'expiryYear': expiryYear
, 'cardSecurityCode': cardSecurityCode
, 'scheme': scheme
}
# Performs the query
answer = client.service.createPayment(
commonRequest=commonRequest,
paymentRequest=paymentRequest,
cardRequest=cardRequest,
orderRequest=orderRequest
)
# Validates the answer
self.validate(client.last_received())
self.logger.info("'createPayment' response for order id {} is valid".format(orderId))
# Returns the answer
return answer
开发者ID:LaurentGrimaud,项目名称:PayZen-Python-SOAP-V5-createPayment-example,代码行数:62,代码来源:PayZenSOAPV5ToolBox.py
示例10: setSMSAOMTSoapHeader
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def setSMSAOMTSoapHeader():
#http身份验证
t = HttpAuthenticated(username=SMS_USERNAME, password=SMS_PASSWORD)
client = Client(SMS_WSDL_URL, transport=t,location=SMS_ISAG_URL)
wsans = ('tns', SMS_NAME_SPACE)
soapHeader = Element("RequestSOAPHeader",ns = wsans)
spId = Element('spId',ns = wsans).setText(SMS_SOAPHEADER_SPID)
#密码MD5加密
m = hashlib.md5()
m.update(SMS_SOAPHEADER_SPPASSWORD)
spPassword= m.hexdigest()
spPassword = Element('spPassword',ns = wsans).setText(spPassword)
timeStamp = Element('timeStamp',ns = wsans).setText(time.strftime('%m%d%H%M%S',time.localtime(time.time())))
productId = Element('productId',ns = wsans).setText(SMS_SOAPHEADER_PRODUCTID)
transactionId = Element('transactionId',ns = wsans).setText(SMS_SOAPHEADER_TRANSID)
transEnd = Element('transEnd',ns = wsans).setText(SMS_SOAPHEADER_TRANS_END)
linkID = Element('linkID',ns = wsans).setText(SMS_SOAPHEADER_LINKID)
OA = Element('OA',ns = wsans).setText(SMS_SOAPHEADER_OA)
FA = Element('FA',ns = wsans).setText(SMS_SOAPHEADER_FA)
multi_castMessaging = Element('multi_castMessaging',ns = wsans).setText(SMS_SOAPHEADER_MULTI_CASTMEG)
soapHeader.append(spId)
soapHeader.append(spPassword)
soapHeader.append(timeStamp)
soapHeader.append(productId)
soapHeader.append(transactionId)
soapHeader.append(transEnd)
soapHeader.append(linkID)
soapHeader.append(OA)
soapHeader.append(FA)
soapHeader.append(multi_castMessaging)
client.set_options(soapheaders=soapHeader)
return client
示例11: ChildcareServiceApi
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
class ChildcareServiceApi(object):
def __init__(self):
url = "https://s3-ap-northeast-1.amazonaws.com" \
"/nursery.novice.io/ReservateChildcareService.xml"
self.client = Client(url)
common_msg = self.client.factory.create('ComMsgHeaderRequest')
common_msg.ServiceKey = CHILDCARE_SERVICE_KEY
self.client.set_options(soapheaders=common_msg)
def get_child_facility_item(self, search_kind, facility_id):
logger.debug("Get child facility item : search_kind=%s, facility_id=%s", search_kind, facility_id)
try:
result = self.client.service.ChildFacilityItem("01", facility_id)
except AttributeError:
raise APILimitError("Getting child faiclity item API exceeds limit : facility_id=%s" % facility_id)
return result
def get_child_facility_list(self, search_kind, page_num):
logger.debug("Get child facility list : search_kind=%s, page_num=%s", search_kind, page_num)
result = self.client.service.ChildFacilityList(
SearchKind="01", PageNum=page_num
)
return result
def get_application_waiting_result_item(self):
pass
示例12: soap_setup
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def soap_setup():
# Create the service interface
printDebugMessage('main', 'WSDL: ' + wsdlUrl, 1)
client = Client(wsdlUrl)
if outputLevel > 1:
print client
global dbfetch
dbfetch = client.service
# Set the client user-agent.
clientRevision = '$Revision: 2467 $'
clientVersion = '0'
if len(clientRevision) > 11:
clientVersion = clientRevision[11:-2]
userAgent = 'EBI-Sample-Client/%s (%s; Python %s; %s) suds/%s Python-urllib/%s' % (
clientVersion, os.path.basename(__file__),
platform.python_version(), platform.system(),
suds.__version__, urllib2.__version__
)
printDebugMessage('main', 'userAgent: ' + userAgent, 1)
httpHeaders = {'User-agent': userAgent}
client.set_options(headers=httpHeaders)
# Configure HTTP proxy from OS environment (e.g. http_proxy="http://proxy.example.com:8080")
proxyOpts = dict()
if os.environ.has_key('http_proxy'):
proxyOpts['http'] = os.environ['http_proxy'].replace('http://', '')
elif os.environ.has_key('HTTP_PROXY'):
proxyOpts['http'] = os.environ['HTTP_PROXY'].replace('http://', '')
if 'http' in proxyOpts:
client.set_options(proxy=proxyOpts)
示例13: __init__
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
class WebServiceClient:
def __init__(self, webservice_type, host, port, ssl, username, password):
"""Base class for clients querying the Coverity web services API.
Keyword arguments:
webservice_type -- either 'configuration' or 'defect'
host -- host of Coverity Connect
port -- port of Coverity Connect
ssl -- True if to use SSL
username -- Coverity Connect account
password -- Coverity Connect password
"""
url = ''
if (ssl):
url = 'https://' + host + ':' + port
else:
url = 'http://' + host + ':' + port
if webservice_type == 'configuration':
self.wsdlFile = url + '/ws/v9/configurationservice?wsdl'
elif webservice_type == 'defect':
self.wsdlFile = url + '/ws/v9/defectservice?wsdl'
else:
raise "unknown web service type: " + webservice_type
self.client = Client(self.wsdlFile)
self.security = Security()
self.token = UsernameToken(username, password)
self.security.tokens.append(self.token)
self.client.set_options(wsse=self.security)
def getwsdl(self):
"""Retrieve the SOAP Client."""
print(self.client)
示例14: get_order_list_test
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def get_order_list_test():
# date_from = "2010-05-05"
date_from = None
date_to = None
UID = "5f719f9e-3b78-4f83-8b3e-6a64cbc84206"
client = Client(_DEVELOPING_ADDRESS_+'privetoffice.1cws?wsdl', location = _DEVELOPING_ADDRESS_+"privetoffice.1cws")
client.set_options(cache=DocumentCache())
result = client.service.OrderLists(UID,date_from,date_to)
orders = ""
i = 0
for order in result[2][0]:
print """
<div class="orderItem """+str(i)+""" ">
<div>
<span class="openOrderDownload">"""+str(order[3])+"""</span>
<span>"""+str(order[2])+"""</span>
<span class="orderDate">"""+str(order[1].split(" ")[0])+"""</span>
</div>
<p class="orderDownload">
Скачать заказ:
<a href='javascript:openLink(\""""+str(order[0])+"""\","xlsx")' title="Скачать заказ в формате xls"> xls </a>
<a href='javascript:openLink(\""""+str(order[0])+"""\","pdf")' title="Скачать заказ в формате pdf"> pdf </a>
<a href='javascript:openLink(\""""+str(order[0])+"""\","odf")' title="Скачать заказ в формате ods"> ods </a>
</p>
</div>
"""
i = i + 1
示例15: get_tab_part_order
# 需要导入模块: from suds.client import Client [as 别名]
# 或者: from suds.client.Client import set_options [as 别名]
def get_tab_part_order(UID):
# cache cleaning code
# import os
# import shutil
# from tempfile import gettempdir as tmp
# shutil.rmtree(os.path.join(tmp(), 'suds'), True)
if UID is not None:
client = Client(_CURRENT_ADDRESS_ + "privetoffice.1cws?wsdl", location=_CURRENT_ADDRESS_ + "privetoffice.1cws")
# client.set_options(cache=None)
client.set_options(cache=DocumentCache())
# print client.service.GetOrders(UID)
try:
result = client.service.GetTabPartOrder(UID)
# return result
except:
return "<p>Ошибка в работе с веб сервисом</p>"
# print result
return result