本文整理汇总了Python中zeep.transports.Transport方法的典型用法代码示例。如果您正苦于以下问题:Python transports.Transport方法的具体用法?Python transports.Transport怎么用?Python transports.Transport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zeep.transports
的用法示例。
在下文中一共展示了transports.Transport方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from zeep import transports [as 别名]
# 或者: from zeep.transports import Transport [as 别名]
def __init__(self, hostname=None, username=None, password=None):
"""
:param hostname:
Checkmarx hostname
:param username:
Checkmarx username
:param password:
Checkmarx password
"""
self.logger = configure_logging(logging.getLogger(__name__))
self.hostname = hostname
self.username = username
self.password = password
self.resolver_url = "%s/cxwebinterface/cxwsresolver.asmx?wsdl" % self.hostname
session = Session()
session.verify = False
self.transport = Transport(session=session)
try:
self._resolver_client = Client(self.resolver_url, transport=self.transport)
except Exception as error:
self.logger.error("Checkmarx connection failed: {error}".format(error=error))
raise ConnectionError(f"Checkmarx connection failed. Wrong or inaccessible hostname: {hostname}") from None
self.session_id = None
self.clients = {}
示例2: __init__
# 需要导入模块: from zeep import transports [as 别名]
# 或者: from zeep.transports import Transport [as 别名]
def __init__(self, wsdl, settings):
session = Session()
transport = Transport(session=session, cache=ZeepCache())
session.auth = HTTPBasicAuth(settings.get('username'), settings.get('password'))
self.client = Client(wsdl, transport=transport)
self.factory = self.client.type_factory('ns0')
示例3: _generate_transport
# 需要导入模块: from zeep import transports [as 别名]
# 或者: from zeep.transports import Transport [as 别名]
def _generate_transport(self) -> zeep.transports.Transport:
return NetSuiteTransport(
self._generate_wsdl_url(), session=self.session, cache=self.cache,
)
示例4: get_soap_client
# 需要导入模块: from zeep import transports [as 别名]
# 或者: from zeep.transports import Transport [as 别名]
def get_soap_client(wsdlurl, timeout=30): # pragma: no cover (not part of normal test suite)
"""Get a SOAP client for performing requests. The client is cached. The
timeout is in seconds."""
# this function isn't automatically tested because the functions using
# it are not automatically tested
if (wsdlurl, timeout) not in _soap_clients:
# try zeep first
try:
from zeep.transports import Transport
transport = Transport(timeout=timeout)
from zeep import CachingClient
client = CachingClient(wsdlurl, transport=transport).service
except ImportError:
# fall back to non-caching zeep client
try:
from zeep import Client
client = Client(wsdlurl, transport=transport).service
except ImportError:
# other implementations require passing the proxy config
try:
from urllib import getproxies
except ImportError:
from urllib.request import getproxies
# fall back to suds
try:
from suds.client import Client
client = Client(
wsdlurl, proxy=getproxies(), timeout=timeout).service
except ImportError:
# use pysimplesoap as last resort
try:
from pysimplesoap.client import SoapClient
client = SoapClient(
wsdl=wsdlurl, proxy=getproxies(), timeout=timeout)
except ImportError:
raise ImportError(
'No SOAP library (such as zeep) found')
_soap_clients[(wsdlurl, timeout)] = client
return _soap_clients[(wsdlurl, timeout)]
示例5: __init__
# 需要导入模块: from zeep import transports [as 别名]
# 或者: from zeep.transports import Transport [as 别名]
def __init__(self, account=None, caching=True, caching_timeout=2592000):
"""
Initialize the Zeep SOAP client, parse the xsd specifications
of Netsuite and store the complex types as attributes of this
instance.
:param str account_id: Account ID to connect to
:param str caching: If caching = 'sqlite', setup Sqlite caching
:param int caching_timeout: Timeout in seconds for caching.
If None, defaults to 30 days
"""
self.logger = logging.getLogger(self.__class__.__name__)
assert account, 'Invalid account'
assert '-' not in account, 'Account cannot have hyphens, it is likely an underscore'
self._account = account
self._wsdl_url = self.WSDL_URL_TEMPLATE.format(account=account.replace('_', '-'))
self._datacenter_url = self.DATACENTER_URL_TEMPLATE.format(account=account.replace('_', '-'))
if caching:
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'cache.db')
timeout = caching_timeout
cache = SqliteCache(path=path, timeout=timeout)
transport = Transport(cache=cache)
else:
transport = None
# Initialize the Zeep Client
self._client = Client(self._wsdl_url, transport=transport)
# default service points to wrong data center. need to create a new service proxy and replace the default one
self._service_proxy = self._client.create_service('{urn:platform_2019_1.webservices.netsuite.com}NetSuiteBinding', self._datacenter_url)
# Parse all complex types specified in :const:`~netsuitesdk.netsuite_types.COMPLEX_TYPES`
# and store them as attributes of this instance. Same for simple types.
self._namespaces = {}
self._init_complex_types()
self._init_simple_types()
self._app_info = None
self._is_authenticated = False
self.set_search_preferences()