Esempio n. 1
0
def web_pc():
    web_service = client.Client(
        url=
        'http://120.24.235.105:9010/sms-service-war-1.0/ws/smsFacade.ws?wsdl')
    web_service = client.Client(
        url=
        'http://120.24.235.105:9010/finance-user_info-war-1.0/ws/financeUserInfoFacade.ws?wsdl'
    )
    print(web_service)
Esempio n. 2
0
 def __init__(self, url):
     self._url = url
     print '[INFO] Start SIGEPWEB webservice connection...'
     try:
         self._service = client.Client(url).service
     except client.TransportError as e:
         raise ErroConexaoComServidor(e.message)
Esempio n. 3
0
    def getInstance(cls, userAPIUrl=None, username=None, password=None):

        if cls._instance is None or (userAPIUrl is not None or username
                                     is not None or password is not None):

            if userAPIUrl is None:
                userAPIUrl = getVidyoOptionValue('userAPIURL')
            if username is None:
                username = getVidyoOptionValue('indicoUsername')
            if password is None:
                password = getVidyoOptionValue('indicoPassword')

            location = getVidyoOptionValue(
                'baseAPILocation') + getVidyoOptionValue('userAPIService')
            try:
                cls._instance = client.Client(
                    userAPIUrl,
                    transport=ClientBase.getTransport(userAPIUrl, username,
                                                      password),
                    location=location,
                    cache=ClientBase.getCache())
            except Exception:
                Logger.get("Vidyo").exception("Problem building UserClient")
                raise

        return cls._instance
Esempio n. 4
0
    def _setup(self):
        plugings = []
        cache_conf = NoCache()
        if Configuration.debug:
            if Configuration.log_file is not None:
                logging.basicConfig(filename=Configuration.log_file, level=Configuration.log_level,
                                    format=utils.get_log_format())
            else:
                logging.basicConfig(level=Configuration.log_level,
                                    format=utils.get_log_format())

            if Configuration.log_level == logging.DEBUG and Configuration.environment ==  constants.PRODUCTION_ENV:
                raise LogException

            plugings.append(LogPlugin())


        s = requests.Session()
        s.mount('file://', FileAdapter())
        if Configuration.proxy_url:
            s.proxies = utils.get_builded_proxy_url(Configuration.proxy_url, Configuration.proxy_port)
            if Configuration.proxy_user:
                s.auth= HTTPProxyAuth(Configuration.proxy_user, Configuration.proxy_pass)

        if Configuration.certificate and Configuration.c_key:
            s.cert=(Configuration.certificate, Configuration.c_key)
        else:
            s.verify = Configuration.certificate

        t = RequestsTransport(s, timeout=Configuration.timeout)

        if Configuration.cache:
            cache_conf = ObjectCache(location=Configuration.cache_location, seconds=Configuration.cache_duration)

        self._client = client.Client(Configuration.get_wsdl().strip(), plugins=plugings, transport=t, cache=cache_conf)
Esempio n. 5
0
 def __init__(self, merchant_id, callback_address):
     if not isinstance(merchant_id, str):
         raise TypeError('merchant_id is str not %s' % type(merchant_id))
     if not isinstance(callback_address, str) and not isinstance(callback_address, unicode):
         raise TypeError('callback_address is unicode or str not %s' % type(callback_address))
     self.__merchant_id__ = merchant_id
     self.__call_address__ = callback_address
     self.__cli__ = client.Client(self.SERVICE_ADDRESS)
Esempio n. 6
0
def get_online_vso_url(api, url, port):
    if api is None and (url is None or port is None):
        for mirror in DEFAULT_URL_PORT:
            if check_connection(mirror['url']):
                api = client.Client(mirror['url'],
                                    transport=mirror['transport']())
                api.set_options(port=mirror['port'])
                return api
Esempio n. 7
0
    def requests(self, url, interface, data):

        self.wsc = client.Client(url)
        try:
            response = eval("self.wsc.service.{}({})".format(interface, data))
        except suds.WebFault as e:
            return dict(e.fault)
        else:
            return dict(response)
    def __init__(self,
                 user=None,
                 password=None,
                 SID=None,
                 close_on_exit=True,
                 lite=False):

        #"""Create the SOAP clients. user and password for premium access."""
        self._SID = SID
        self._close_on_exit = close_on_exit
        search_wsdl = self.searchlite_url if lite else self.search_url
        self._auth = client.Client(self.auth_url)
        self._search = client.Client(search_wsdl)

        if user and password:
            auth = '%s:%s' % (user, password)
            auth = _b64encode(auth.encode('utf-8')).decode('utf-8')
            headers = {'Authorization': ('Basic %s' % auth).strip()}
            self._auth.set_options(headers=headers)
Esempio n. 9
0
    def __init__(self, url=None, port=None, api=None):
        if api is None:
            if url is None:
                url = DEFAULT_URL
            if port is None:
                port = DEFAULT_PORT

            api = client.Client(url)
            api.set_options(port=port)
        self.api = api
Esempio n. 10
0
    def __init__(self, url=None, port=None, api=None):
        if api is None:
            if url is None:
                url = DEFAULT_URL
            if port is None:
                port = DEFAULT_PORT

            api = client.Client(url, transport=WellBehavedHttpTransport())
            api.set_options(port=port)
        self.api = api
Esempio n. 11
0
 def do_setup(self, context):
     """Create client for DISCO request manager."""
     LOG.debug("Enter in DiscoDriver do_setup.")
     if CONF.choice_client.lower() == "rest":
         self.client = disco_api.DiscoApi(
             CONF.rest_ip, CONF.disco_src_api_port)
     else:
         path = ''.join(['file:', self.configuration.disco_wsdl_path])
         init_client = client.Client(path, cache=None)
         self.client = init_client.service
Esempio n. 12
0
 def _create_client(self, wsdl_url, login, password, hostname, port):
     """
     Instantiate a "suds" client to make web services calls to the
     DFM server. Note that the WSDL file is quite large and may take
     a few seconds to parse.
     """
     self.client = client.Client(wsdl_url,
                                 username=login,
                                 password=password)
     soap_url = 'http://%s:%s/apis/soap/v1' % (hostname, port)
     self.client.set_options(location=soap_url)
 def __init__(self, settings):
     self.settings = settings
     security = wsse.Security()
     token = wsse.UsernameToken(
         self.settings.get('username'), self.settings.get('password'))
     security.tokens.append(token)
     # settings faults to False makes sure we can catch the server side
     # exception message as well
     self.client = client.Client(
         self.settings.get('wsdl'), autoblend=True,
         wsse=security, faults=False)
Esempio n. 14
0
    def get_soap_client(wsdl_path, **kwargs):
        """
        Create a soap client based on suds and python requests (to handle the AlgoSec's self-signed certificate properly

        :param kwargs: KWArgs that are forwarded to the suds client constructor
        """
        session = requests.Session()
        session.verify = False
        return client.Client(
            wsdl_path,
            transport=suds_requests.RequestsTransport(session),
            **kwargs)
Esempio n. 15
0
    def test_report_soap_failure__detailed_transport_error(self):
        wsdl_path = "http://some-wsdl-path"
        api_error = "some error description"
        responses.add(responses.GET, wsdl_path, json={"error": api_error}, status=500)

        with pytest.raises(AlgoSecAPIError) as e:
            with report_soap_failure(AlgoSecAPIError):
                # Force an api soap call, that is destined to fail
                client.Client(wsdl_path, transport=suds_requests.RequestsTransport())

        assert "status_code: 500" in str(e)
        assert api_error in str(e)
    def post(self, request):
        try:
            user = request.user
            client = user.client
        except:
            return Response(status=status.HTTP_401_UNAUTHORIZED)
        serializer = PurchaseArticleSerializer(data=request.data)
        if serializer.is_valid():
            articleId = serializer.validated_data["articleID"]
            platform = str(serializer.validated_data["platform"])
            if Article.objects.filter(id=articleId).exists() is False:
                return Response(status=status.HTTP_400_BAD_REQUEST)
            if platform != "Android" and platform != "iOS":
                return Response(status=status.HTTP_400_BAD_REQUEST)
            article = Article.objects.get(id=articleId)
            if article in client.purchasedArticles.all():
                return Response(status=status.HTTP_400_BAD_REQUEST)
            if article.price == 0:
                return Response(status=status.HTTP_400_BAD_REQUEST)

            if PurchaseBankID.objects.filter(article=article,
                                             client=client).exists():
                PurchaseBankID.objects.filter(article=article,
                                              client=client).delete()
            price = article.price
            if article.isPersian:
                description = "خرید مقاله: " + article.title
            else:
                description = "Purchasing Article: " + article.title
            zarin_client = C1.Client(ZARINPAL_WEBSERVICE)
            absolute_url = request.build_absolute_uri('/')
            call_back_url = absolute_url + 'api/v1/article/purchase/callback/'
            result = zarin_client.service.PaymentRequest(
                MerchantID=MMERCHANT_ID,
                Amount=price,
                Description=description,
                CallbackURL=call_back_url,
            )
            if result.Status == 100:
                authorizationID = str(result.Authority)
                PurchaseBankID.objects.create(article=article,
                                              client=client,
                                              authorityID=authorizationID,
                                              platform=platform)
                zarin_url = 'https://www.zarinpal.com/pg/StartPay/' + authorizationID
            else:
                return Response(status=status.HTTP_400_BAD_REQUEST)
            result['url'] = zarin_url
            return Response(result, status=status.HTTP_200_OK)

        else:
            return Response(status=status.HTTP_400_BAD_REQUEST)
Esempio n. 17
0
def workday_client_login(*args, **kwargs):
    wsdl_url = kwargs['wsdl_url']
    username = kwargs['username']
    password = kwargs['password']
    proxy = kwargs['proxy']
    client_return = None
    print "Connecting to wsdl_url ..."
    try:
        if (proxy.strip() != ""):
            client_return = client.Client(wsdl_url, proxy={'https': proxy})
        else:
            client_return = client.Client(wsdl_url)
        security = Security()
        token = UsernameToken(username, password)
        security.tokens.append(token)
        client_return.set_options(wsse=security)
    except Exception as e:
        print(e)
        return client_return

    print("Logged In to: " + wsdl_url)
    return client_return
Esempio n. 18
0
 def __init__(self, wsdl_url=None, soap_url=None,
              cacert=None, insecure=True, pool_maxsize=10):
     self.wsdl_url = wsdl_url
     self.soap_url = soap_url
     LOG.debug("Creating suds client with soap_url='%s' and wsdl_url='%s'",
               self.soap_url, self.wsdl_url)
     transport = RequestsTransport(cacert, insecure, pool_maxsize)
     self.client = client.Client(self.wsdl_url,
                                 transport=transport,
                                 location=self.soap_url,
                                 plugins=[ServiceMessagePlugin()],
                                 cache=_CACHE)
     self._service_content = None
Esempio n. 19
0
    def _create_client(self, **kwargs):
        """Instantiate a web services client.

        This method creates a "suds" client to make web services calls to the
        DFM server. Note that the WSDL file is quite large and may take
        a few seconds to parse.
        """
        wsdl_url = kwargs['wsdl_url']
        LOG.debug(_('Using WSDL: %s') % wsdl_url)
        if kwargs['cache']:
            self.client = client.Client(wsdl_url,
                                        username=kwargs['login'],
                                        password=kwargs['password'])
        else:
            self.client = client.Client(wsdl_url,
                                        username=kwargs['login'],
                                        password=kwargs['password'],
                                        cache=None)
        soap_url = 'http://%s:%s/apis/soap/v1' % (kwargs['hostname'],
                                                  kwargs['port'])
        LOG.debug(_('Using DFM server: %s') % soap_url)
        self.client.set_options(location=soap_url)
Esempio n. 20
0
	def _build(self):
		#this is used for performance, wsdl and header will be built on initialization of object to save time and redudancy
		wsdl_url = 'https://wd2-impl-services1.workday.com/ccx/service/' + self.tenant + '/' + self.wws + '/' + self.version +'?wsdl'
		print wsdl_url
		print self.username +'\n' + 'building wsdl for ' + self.wws + ' object'
		self.client1 = client.Client(wsdl_url)
		# Wrapping our client call in Security() like this results in submitting
		# the auth request with PasswordType in headers in the format WD expects.
		security = Security()
		token = UsernameToken(self.username, self.password)
		security.tokens.append(token)
		self.client1.set_options(wsse=security)
		print '\n'+ ' wsdl and header has been built'
Esempio n. 21
0
    def call(self, name, **data):
        log.info('IARC client call: {0} from wsdl: {1}'.format(name, wsdl))

        if self.client is None:
            self.client = sudsclient.Client(wsdl[self.wsdl_name], cache=None)

        # IARC requires messages be base64 encoded.
        for k, v in data.items():
            data[k] = base64.b64encode(v)

        with statsd.timer('mkt.iarc.request.%s' % name.lower()):
            response = getattr(self.client.service, name)(**data)

        return base64.b64decode(response)
Esempio n. 22
0
 def get_ret(case):
     try:
         web_service = client.Client(url=case.url)
         string = f'web_service.service.{case.api_name}({case.request_data})'
         actual = eval(string)
     except WebFault as e:
         actual = {
             'retCode': e.fault.faultcode,
             'retInfo': e.fault.faultstring
         }
         print(e)
     else:
         actual = dict(actual)
     return actual
 def send(url, method, *args, **kwargs):
     # 创建客户端对象
     cli = client.Client(url=url)
     # 根据参数构造请求方法
     request_method = eval('cli.service.{}'.format(method))
     try:
         # 发送请求
         res = request_method(*args, **kwargs)
     except suds.WebFault as e:
         # 提取请求错误信息返回
         return dict(e.fault)
     else:
         # 返回正常的信息
         return dict(res)
Esempio n. 24
0
    def web_request(self, url, interface, data):

        self.webs = client.Client(
            url=url)  # 传入url,创建webservice对象,打印对象可查看对象内部的方法

        try:
            response = eval('self.webs.service.{}({})'.format(
                interface, data))  # 拼接参数,并将str转换成python语句

        except suds.WebFault as e:
            # 服务器返回的数据在e.fault内,可转换成dict
            return dict(e.fault)
        else:
            return dict(response)
Esempio n. 25
0
 def __init__(self, *args, **kwargs):
     self.sid = None
     self.username = kwargs['username']
     self.password = kwargs['password']
     wsdl_url = 'https://%s/wsdl/NsGroupManagement.wsdl' % (kwargs['ip'])
     LOG.debug('Using Nimble wsdl_url: %s', wsdl_url)
     self.err_string_dict = self._create_err_code_to_str_mapper(wsdl_url)
     self.client = client.Client(wsdl_url,
                                 username=self.username,
                                 password=self.password)
     soap_url = ('https://%(ip)s:%(port)s/soap' % {'ip': kwargs['ip'],
                                                   'port': SOAP_PORT})
     LOG.debug('Using Nimble soap_url: %s', soap_url)
     self.client.set_options(location=soap_url)
     self.login()
Esempio n. 26
0
    def __init__(self, host, username, password, timeout):
        if websocket is None:
            msg = _("Failed to import websocket-client python module."
                    " Please, ensure the module is installed.")
            raise datacore_exceptions.DataCoreException(msg)

        self.timeout = timeout

        executive_service_net_addr = datacore_utils.build_network_address(
            host, self.DATACORE_EXECUTIVE_PORT)
        executive_service_endpoint = self._build_service_endpoint(
            executive_service_net_addr, self.EXECUTIVE_SERVICE)

        security_options = wsse.Security()
        username_token = wsse.UsernameToken(username, password)
        security_options.tokens.append(username_token)

        self._executive_service_client = suds_client.Client(
            executive_service_endpoint['http_endpoint'] + '?singlewsdl',
            nosend=True,
            timeout=self.timeout,
            wsse=security_options,
            plugins=[FaultDefinitionsFilter()])

        self._update_storage_services_endpoint(executive_service_endpoint)

        storage_services_endpoint = self._get_storage_services_endpoint()

        self._storage_services_client = suds_client.Client(
            storage_services_endpoint['http_endpoint'] + '?singlewsdl',
            nosend=True,
            timeout=self.timeout,
            wsse=security_options,
            plugins=[FaultDefinitionsFilter()])

        self._update_executive_service_endpoints(storage_services_endpoint)
Esempio n. 27
0
    def call(self, name, **data):
        log.info('IARC client call: {0} from wsdl: {1}'.format(name, wsdl))

        if self.client is None:
            self.client = sudsclient.Client(wsdl[self.wsdl_name], cache=None)

        # IARC requires messages be base64 encoded and base64 requires
        # byte-strings.
        for k, v in data.items():
            if isinstance(v, unicode):
                # Encode it as a byte-string.
                v = v.encode('utf-8')
            data[k] = base64.b64encode(v)

        with statsd.timer('mkt.iarc.request.%s' % name.lower()):
            response = getattr(self.client.service, name)(**data)

        return base64.b64decode(response)
Esempio n. 28
0
	def connect(self):		
		eds_wsdl = '%s://%s:%i/eds.wsdl' % (config.EDS_WEB_PROTOCOL,config.EDS_HOST,config.EDS_WEB_PORT)
		connected = False
		authorized = False
		try:
			self.soap_cln = client.Client(eds_wsdl)
			self.logger.debug('[EDS_connector] Successfully connected to EDS')
			connected = True
		except Exception as conn_error:
			self.logger.debug('[EDS_connector] WSDL connection error to %s, %s' % (eds_wsdl, conn_error))
		if connected:
			try:
				self.auth_str = self.soap_cln.service.login(config.EDS_USER, config.EDS_PWD)
				self.logger.debug('[EDS_connector] Successfully authorized in EDS')
				authorized = True
			except Exception as auth_error:
				self.logger.debug('[EDS_connector] WebApi authorisation error with user %s and pass %s, %s' % (config.EDS_USER, config.EDS_PWD, auth_error))
		if connected and authorized:
				self.connected = True
Esempio n. 29
0
 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
 def get(self, request):
     zarin_status = request.query_params.get('Status', None)
     authorizationID = str(request.query_params.get('Authority', None))
     if PurchaseBankID.objects.filter(
             authorityID=authorizationID).exists() is False:
         return Response(status=status.HTTP_400_BAD_REQUEST)
     bankID = PurchaseBankID.objects.get(authorityID=authorizationID)
     platform = bankID.platform
     article = bankID.article
     if zarin_status == 'OK':
         zarin_client = C1.Client(ZARINPAL_WEBSERVICE)
         result = zarin_client.service.PaymentVerification(
             MerchantID=MMERCHANT_ID,
             Authority=authorizationID,
             Amount=bankID.article.price,
         )
         if result.Status == 100:
             client = bankID.client
             article = bankID.article
             client.purchasedArticles.add(article)
             client.save()
             bankID.delete()
             platform = "Android"
             article = Article.objects.get(id=1)
             if platform == 'iOS':
                 app_url = 'monencoinsights://?status=1&article=' + str(
                     article.id)
             else:
                 app_url = "intent://www.monencoinsights.com/#Intent;scheme=monenco;package=com.monenco.insights;i.status=1;i.article={};end".format(
                     str(article.id))
             print(app_url)
             response = HttpResponse("", status=302)
             response['Location'] = app_url
             return response
     if platform == 'iOS':
         app_url = 'monencoinsights://?status=0&article=' + str(article.id)
     else:
         app_url = "intent://www.monencoinsights.com/#Intent;scheme=monenco;package=com.monenco.insights;i.status=0;i.article={};end".format(
             str(article.id))
     response = HttpResponse("", status=302)
     response['Location'] = app_url
     return response