Пример #1
0
def get_soap_client(
        wsdlurl):  # pragma: no cover (not part of normal test suite)
    """Get a SOAP client for performing requests. The client is cached."""
    # this function isn't automatically tested because the functions using
    # it are not automatically tested
    if wsdlurl not in _soap_clients:
        try:
            from urllib import getproxies
        except ImportError:
            from urllib.request import getproxies
        # try zeep first
        try:
            from zeep import CachingClient
            client = CachingClient(wsdlurl).service
        except ImportError:
            # fall back to suds
            try:
                from suds.client import Client
                client = Client(wsdlurl, proxy=getproxies()).service
            except ImportError:
                # use pysimplesoap as last resort
                from pysimplesoap.client import SoapClient
                client = SoapClient(wsdl=wsdlurl, proxy=getproxies())
        _soap_clients[wsdlurl] = client
    return _soap_clients[wsdlurl]
Пример #2
0
    def __init__(self, base_url: str = None):
        """
        Initializer for the class.

        :param base_url: Base URL of the memoQ Web Service API, as a string.  For example: "http://localhost:8080"
        """
        self.base_url = base_url if base_url is not None else DEFAULT_BASE_URL
        self.__client = CachingClient(wsdl=self.service_url)
Пример #3
0
    def __init__(self, login: str, password: str):
        """
        Инициализация API клиента сервиса отслеживания посылок.

        :param login: Логин от системы трекинга
        :param password: Пароль от системы трекинга
        """
        self._login = login
        self._password = password

        self._client = CachingClient(
            'https://tracking.russianpost.ru/rtm34?wsdl',
            settings=Settings(strict=False),
        )
Пример #4
0
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
0
def create_client(wsdl: str, raw_response: bool = True) -> CachingClient:
    """
    Creates Zeep client that caches the WSDL.

    :param str wsdl: Link to the WSDL
    :param bool raw_response: Whether the client should return the raw XML response
    :return CachingClient client: Zeep client
    """
    # We want the raw response as there is an error when Zeep parses the XML
    settings: Settings = Settings(raw_response=raw_response)

    # Client that caches the WSDL
    client: CachingClient = CachingClient(
        wsdl=wsdl,
        # TODO: Store PW encrypted
        wsse=UsernameToken("n00394gz", "g427Ix19LMB"),
        settings=settings,
    )
    logger.debug(f"Client created")

    return client
Пример #6
0
#!/usr/bin/env python3

from zeep import CachingClient as Client

client = Client(wsdl='http://sympa.bard.edu/sympa/wsdl')
with client.settings(strict=False):
    response = client.service.authenticateRemoteAppAndRun(
        'provisioning', 'SympApR0vision', '[email protected]',
        'complexWhich', [])

print(response)
for item in response:
    print(dir(item))
    print(item.values())
Пример #7
0
from zeep import CachingClient
from zeep.plugins import HistoryPlugin
import json
from .enums import *
from pathlib import Path
from datetime import datetime

# Load config file
base_path = Path(__file__).parent
file_path = (base_path / "./config.json").resolve()
with open(file_path) as config_file:
    config = json.load(config_file)

history = HistoryPlugin()
client = CachingClient(config['WSDL'], plugins=[history])
"""
IMPORTANT
Data types (even if empty) must be defined and must match the types in the API reference.
Otherwise, the server will return no XML data, and zeep will throw a zeep.exceptions.TransportError
"""


class ServiceRequest:
    """
    Defines what kind of data to return from the service
    Input a list of molecule_flags or reaction_flags to retrieve more data
    """
    def __init__(
            self,
            page: int = 1,
            count: int = 200,
Пример #8
0
 def __init__(self, url):
     s = Session()
     s.verify = False
     self.client = CachingClient(wsdl=url, transport=Transport(session=s))