本文整理汇总了Python中suds.client.Client方法的典型用法代码示例。如果您正苦于以下问题:Python client.Client方法的具体用法?Python client.Client怎么用?Python client.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suds.client
的用法示例。
在下文中一共展示了client.Client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_slb_service_client
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def create_slb_service_client(self):
def soap_header():
request_header = suds_element.Element('RequestHeader',
ns=AdxService.ns0)
context = suds_element.Element('context').setText('default')
request_header.append(context)
return request_header
url = self.wsdl_base + self.slb_service_wsdl
location = 'https://' + self.adx_ip_address + '/WS/SLB'
start = time.time()
client = suds_client.Client(url, transport=self.transport,
service='AdcSlb',
location=location, timeout=self.timeout,
plugins=[RemoveEmptyTags()])
elapsed = (time.time() - start)
LOG.debug('Time to initialize SLB Service Client: %s', elapsed)
request_header = soap_header()
client.set_options(soapheaders=request_header)
return client
示例2: create_sys_service_client
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def create_sys_service_client(self):
def soap_header():
request_header = suds_element.Element('RequestHeader',
ns=AdxService.ns0)
context = suds_element.Element('context').setText('default')
request_header.append(context)
return request_header
url = self.wsdl_base + self.sys_service_wsdl
location = 'https://' + self.adx_ip_address + '/WS/SYS'
start = time.time()
client = suds_client.Client(url, transport=self.transport,
service='AdcSysInfo',
location=location, timeout=self.timeout,
plugins=[RemoveEmptyTags()])
elapsed = (time.time() - start)
LOG.debug('Time to initialize SYS Service Client: %s', elapsed)
request_header = soap_header()
client.set_options(soapheaders=request_header)
return client
示例3: create_net_service_client
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def create_net_service_client(self):
def soap_header():
request_header = suds_element.Element('RequestHeader',
ns=AdxService.ns0)
context = suds_element.Element('context').setText('default')
request_header.append(context)
return request_header
url = self.wsdl_base + self.net_service_wsdl
location = 'https://' + self.adx_ip_address + '/WS/NET'
start = time.time()
client = suds_client.Client(url, transport=self.transport,
service='AdcNet',
location=location,
timeout=self.timeout,
plugins=[RemoveEmptyTags()])
elapsed = (time.time() - start)
LOG.debug('Time to initialize NET Service Client: %s', elapsed)
request_header = soap_header()
client.set_options(soapheaders=request_header)
return client
示例4: __init__
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def __init__(self, wsdl=None, api_key=None, timeout=5):
"""
Constructor
Keyword arguments:
wsdl -- the URL of the Darwin LDB WSDL document. Will fall back to
using the DARWIN_WEBSERVICE_WSDL environment variable if not supplied
api_key -- a valid API key for the Darwin LDB webservice. Will fall
back to the DARWIN_WEBSERVICE_API_KEY if not supplied
timeout -- a timeout in seconds for calls to the LDB Webservice
(default 5)
"""
if not wsdl:
wsdl = os.environ["DARWIN_WEBSERVICE_WSDL"]
if not api_key:
api_key = os.environ["DARWIN_WEBSERVICE_API_KEY"]
self._soap_client = Client(wsdl, transport=WellBehavedHttpTransport())
self._soap_client.set_options(timeout=timeout)
# build soap headers
token3 = Element("AccessToken", ns=DARWIN_WEBSERVICE_NAMESPACE)
token_value = Element("TokenValue", ns=DARWIN_WEBSERVICE_NAMESPACE)
token_value.setText(api_key)
token3.append(token_value)
self._soap_client.set_options(soapheaders=(token3))
示例5: update_WoRMS_lineages
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def update_WoRMS_lineages(self, LineageNames, query_name, source_feature):
cl = Client('http://www.marinespecies.org/aphia.php?p=soap&wsdl=1')
scinames = cl.factory.create('scientificnames')
scinames["_arrayType"] = "string[]"
scinames["scientificname"] = [query_name]
array_of_results_array = cl.service.matchAphiaRecordsByNames(scinames, like="true", fuzzy="true",
marine_only="false")
# 有时一个名字会搜出来几个,存在列表中[[<suds.sudsobject.AphiaRecord object at 0x0000000003EF35C0>, <suds.sudsobject.AphiaRecord object at 0x0000000003EF34E0>], [<suds.sudsobject.AphiaRecord object at 0x0000000003EF3748>]]
if not array_of_results_array[0]:
##没搜到就直接返回
return source_feature
aphia_object = array_of_results_array[0][0]
for lineage in LineageNames:
tax_name = lineage.lower() if lineage.lower() != "class" else "cls"
if hasattr(aphia_object, tax_name):
exec("source_feature.qualifiers[lineage] = aphia_object.%s"%tax_name)
return source_feature
示例6: __init__
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def __init__(self, username, password, url):
# Get Configuration
self.getConfig(username, password, url)
# Open Connection With Checkmarx
self.Initclient = self.openConnection()
# Get the Service URL
self.serviceUrl = self.getServiceUrl(self.Initclient)
# Get the Session Id and Client Object
(self.sessionId, self.client) = self.getSessionId(self.Initclient,self.serviceUrl)
return None
##########################################
#
# Functions Related to Opening session with Checkmarx
#
##########################################
#
# Get Configuration
#
示例7: __init__
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def __init__(self, service_name, login, private_key=None,
private_key_file='decrypted_key', endpoint='api.transip.nl'):
self.service_name = service_name
self.login = login
self.private_key = private_key
self.private_key_file = private_key_file
self.endpoint = endpoint
self.url = URI_TEMPLATE.format(endpoint, service_name)
imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
doc = ImportDoctor(imp)
suds_kwargs = dict()
if suds_requests:
suds_kwargs['transport'] = suds_requests.RequestsTransport()
self.soap_client = SudsClient(self.url, doctor=doc, plugins=[WSDLFixPlugin()], **suds_kwargs)
示例8: __init__
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def __init__(self, wsdl_url=None, soap_url=None,
cacert=None, insecure=True, pool_maxsize=10,
connection_timeout=None, op_id_prefix='oslo.vmware'):
self.wsdl_url = wsdl_url
self.soap_url = soap_url
self.op_id_prefix = op_id_prefix
LOG.debug("Creating suds client with soap_url='%s' and wsdl_url='%s'",
self.soap_url, self.wsdl_url)
transport = RequestsTransport(cacert=cacert,
insecure=insecure,
pool_maxsize=pool_maxsize,
connection_timeout=connection_timeout)
self.client = client.Client(self.wsdl_url,
transport=transport,
location=self.soap_url,
plugins=[ServiceMessagePlugin()],
cache=_CACHE)
self._service_content = None
self._vc_session_cookie = None
示例9: __init__
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def __init__(self, name, url, verbose=True, cache=False):
""".. rubric:: Constructor
:param str name: a name e.g. Kegg, Reactome, ...
:param str url: the URL of the WSDL service
:param bool verbose: prints informative messages
The :attr:`serv` give access to all WSDL functionalities of the service.
The :attr:`methods` is an alias to self.serv.methods and returns
the list of functionalities.
"""
super(WSDLService, self).__init__(name, url, verbose=verbose)
self.logging.info("Initialising %s service (WSDL)" % self.name)
self.CACHING = cache
try:
#: attribute to access to the methods provided by this WSDL service
from suds.client import Client
from suds.cache import ObjectCache
oc = ObjectCache(self.settings.user_config_dir, days=0)
if self.CACHING is True:
self.suds = Client(self.url, cache=oc, cachingpolicy=1)
else:
self.suds = Client(self.url)
# reference to the service
self.serv = self.suds.service
self._update_settings()
except Exception :
self.logging.error("Could not connect to the service %s " % self.url)
raise Exception
示例10: __init__
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def __init__(self, url, user=None, passwd=None):
if user is None:
self.server = Client(url + "?wsdl")
else:
self.server = Client(url=url + "?wsdl", headers={'Username': user, 'Password': passwd})
示例11: __init__
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def __init__(self, client, arg_processor_factory, result_processor_factory,
wsdl_name, debug=False):
"""init
@param client: An instance of suds.client.Client.
@param arg_processor_factory: This will be called to create processors
for arguments before they are passed to suds methods. This callable
will be passed the suds method and factory and should return an
instance of L{_ArgProcessor}.
@param result_processor_factory: This will be called to create
processors for results returned from suds methods. This callable
will be passed no arguments and should return an instance of
L{_ResultProcessor}.
"""
self._client = client
self._arg_factory = arg_processor_factory
self._result_factory = result_processor_factory
self._wsdl_name = wsdl_name
self._usage = {}
# This populates self.__dict__. Helpful for tab completion.
# I'm not sure if this slows things down much. Maybe we should just
# always do it.
if debug:
# Extract the documentation from the WSDL (before populating
# self.__dict__)
binding_el = client.wsdl.services[0].ports[0].binding[0]
for op in binding_el.getChildren("operation"):
usage = None
doc = op.getChild("documentation")
if doc is not None:
usage = doc.getText().strip()
self._usage[op.get("name")] = usage
for method in client.sd[0].ports[0][1]:
getattr(self, method[0])
示例12: rate_request
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def rate_request(self, shipment, message=None):
"""
Contacts to DHL Rate Request to obtain carrier rates for this shipment
:param shipment: DHLShipment object
:param message: optional message
:return: DHLResponse
"""
if not self.shipment_client:
url = self.shipment_test_url if self.test_mode else \
self.shipment_url
self.shipment_client = Client(url, faults=False)
security = Security()
token = UsernameToken(self.username, self.password)
security.tokens.append(token)
self.shipment_client.set_options(wsse=security)
dhl_shipment = self._create_dhl_shipment_type2(self.shipment_client,
shipment)
result_code, reply = self.shipment_client.service.getRateRequest(
None, dhl_shipment)
if result_code == 500:
return DHLPodResponse(False, errors=[reply.detail.detailmessage])
for rate_reply in reply:
notif = rate_reply.Notification
if notif._code != '0':
print('[Code: ' + notif._code + ', '
'Message: ' + notif.Message + ']')
return DHLPodResponse(False, errors=[(notif._code,
notif.Message)])
return DHLRateResponse(True, rate_reply.Service)
示例13: proof_of_delivery
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def proof_of_delivery(self, shipment_awb, detailed=True):
"""
Connects to DHL ePOD service, and returns the POD for the requested shipment.
:param shipment_awb: shipment waybill or identification number
:param detailed: if a detailed POD should be returned, else simple
:return: (True, pdf bytes) if successful else (False, [errors])
"""
if not self.pod_client:
url = self.pod_test_url if self.test_mode else self.pod_url
self.pod_client = Client(url, faults=False)
security = Security()
token = UsernameToken(self.username, self.password)
security.tokens.append(token)
self.pod_client.set_options(wsse=security)
msg = self._create_dhl_shipment_document(shipment_awb, detailed)
code, res = self.pod_client.service.ShipmentDocumentRetrieve(msg)
if code == 500:
return DHLPodResponse(False, errors=[res.detail.detailmessage])
try:
img = res.Bd.Shp[0].ShpInDoc[0].SDoc[0].Img[0]._Img
return DHLPodResponse(True, img)
except:
return DHLPodResponse(False, errors=[error.DatErrMsg.ErrMsgDtl._DtlDsc for error in res.DatTrErr])
示例14: create_client
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def create_client():
global __suds_client
if __suds_client:
return __suds_client
wsdl = 'http://consumer_services_api.talkpython.fm/soap?wsdl'
trans = http.HttpAuthenticated(username='kennedy', password='super_lockdown') # noqa
__suds_client = Client(wsdl, transport=trans)
return __suds_client
示例15: connect
# 需要导入模块: from suds import client [as 别名]
# 或者: from suds.client import Client [as 别名]
def connect(self):
if self.client is None:
# Suds library doesn't support passing unverified context to disable
# server certificate verification. Thus disable checking globally in
# order to skip verification. This is not recommended in production
# code. see https://www.python.org/dev/peps/pep-0476/
if self.skip_verification:
import ssl
try:
_create_unverified_https_context = \
ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by
# default
pass
else:
# Handle target environment that doesn't support HTTPS
# verification
ssl._create_default_https_context = \
_create_unverified_https_context
self.client = Client(url=self.wsdl_url, location=self.soap_url)
assert self.client is not None
self.client.set_options(service='LsService', port='LsPort')
self.managedObjectReference = self.client.factory.create(
'ns0:ManagedObjectReference')
self.managedObjectReference._type = 'LookupServiceInstance'
self.managedObjectReference.value = 'ServiceInstance'
lookupServiceContent = self.client.service.RetrieveServiceContent(
self.managedObjectReference)
self.serviceRegistration = lookupServiceContent.serviceRegistration