コード例 #1
0
ファイル: xnnppx.py プロジェクト: evl2001/xnnppx
 def _call(self, jws, operation, inputs, fix_import=False):
     """perform a SOAP call"""
     url = "%s/axis/%s" % (self._base_url, jws)
     if urlparse.urlparse(url).scheme == "https":
         t = suds.transport.https.HttpTransport()
     else:
         t = suds.transport.http.HttpTransport()
     t.urlopener = urllib2.build_opener(HTTPSudsPreprocessor)
     for h in t.urlopener.handlers:
         if isinstance(h, HTTPSudsPreprocessor):
             h.jsessionid = self._session
     if fix_import:
         xsd_url = "http://schemas.xmlsoap.org/soap/encoding/"
         imp = suds.xsd.doctor.Import(xsd_url)
         doctor = suds.xsd.doctor.ImportDoctor(imp)
         client = suds.client.Client("%s?wsdl" % url, transport=t, doctor=doctor)
     else:
         client = suds.client.Client("%s?wsdl" % url, transport=t)
     typed_inputs = []
     for (dtype, val) in inputs:
         ti = client.factory.create(dtype)
         ti.value = val
         typed_inputs.append(ti)
     # the WSDL returns the local IP address in the URLs; these need
     # to be corrected if XNAT is behind a proxy
     client.set_options(location=url)
     f = getattr(client.service, operation)
     result = f(*typed_inputs)
     return result
コード例 #2
0
ファイル: bigsuds.py プロジェクト: jdubs/f5-cli
def get_client(hostname, wsdl_name, username='******', password='******',
               cachedir=None):
    """Returns and instance of suds.client.Client.

    A separate client is used for each iControl WSDL/Namespace (e.g.
    "LocalLB.Pool").

    This function allows any suds exceptions to propagate up to the caller.

    @param hostname: The IP address or hostname of the BIGIP.
    @param wsdl_name: The iControl namespace (e.g. "LocalLB.Pool")
    @param username: The admin username on the BIGIP.
    @param password: The admin password on the BIGIP.
    @param cachedir: The directory to cache wsdls in. None indicates
        that caching should be disabled.
    """
    url = 'https://%s/iControl/iControlPortal.cgi?WSDL=%s' % (
        hostname, wsdl_name)
    imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
    imp.filter.add('urn:iControl')

    if cachedir is not None:
        cachedir = ObjectCache(location=os.path.expanduser(cachedir), days=1)

    doctor = ImportDoctor(imp)
    client = Client(url, doctor=doctor, username=username, password=password,
                    cache=cachedir)

    # Without this, subsequent requests will use the actual hostname of the
    # BIGIP, which is often times invalid.
    client.set_options(location=url.split('?')[0])
    client.factory.separator('_')
    return client
コード例 #3
0
def addSecurityHeader(client, username, password):
    security = Security()
    userNameToken = UsernameToken(username, password)
    timeStampToken = Timestamp(validity=600)
    security.tokens.append(userNameToken)
    security.tokens.append(timeStampToken)
    client.set_options(wsse=security)
コード例 #4
0
ファイル: bigsuds.py プロジェクト: zachcalvert/bigsuds
def get_client(hostname,
               wsdl_name,
               username='******',
               password='******',
               cachedir=None,
               verify=False,
               timeout=90,
               port=443):
    """Returns and instance of suds.client.Client.

    A separate client is used for each iControl WSDL/Namespace (e.g.
    "LocalLB.Pool").

    This function allows any suds exceptions to propagate up to the caller.

    @param hostname: The IP address or hostname of the BIGIP.
    @param wsdl_name: The iControl namespace (e.g. "LocalLB.Pool")
    @param username: The admin username on the BIGIP.
    @param password: The admin password on the BIGIP.
    @param cachedir: The directory to cache wsdls in. None indicates
        that caching should be disabled.
    @param verify: When True, performs SSL certificate validation in
        Python / urllib2 versions that support it (v2.7.9 and newer)
    @param timeout: The time to wait (in seconds) before timing out
        the connection to the URL
    """
    url = 'https://%s:%s/iControl/iControlPortal.cgi?WSDL=%s' % (
        hostname, port, wsdl_name)
    imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
    imp.filter.add('urn:iControl')

    if cachedir is not None:
        cachedir = ObjectCache(location=os.path.expanduser(cachedir), days=1)

    doctor = ImportDoctor(imp)
    if verify:
        client = Client(url,
                        doctor=doctor,
                        username=username,
                        password=password,
                        cache=cachedir,
                        timeout=timeout)
    else:
        transport = HTTPSTransportNoVerify(username=username,
                                           password=password,
                                           timeout=timeout)
        client = Client(url,
                        doctor=doctor,
                        username=username,
                        password=password,
                        cache=cachedir,
                        transport=transport,
                        timeout=timeout)

    # Without this, subsequent requests will use the actual hostname of the
    # BIGIP, which is often times invalid.
    client.set_options(location=url.split('?')[0])
    client.factory.separator('_')
    return client
コード例 #5
0
ファイル: client.py プロジェクト: Informatic/ppsa-jsonapi
 def connect(self, username=API_PUBLIC_USERNAME,
             password=API_PUBLIC_PASSWORD):
     security = suds.wsse.Security()
     token = suds.wsse.UsernameToken(username, password)
     security.tokens.append(token)
     client = suds.client.Client(API_URL)
     client.set_options(wsse=security)
     self.client = client
コード例 #6
0
ファイル: client.py プロジェクト: q3k/ppsa-jsonapi
 def connect(self, username=API_PUBLIC_USERNAME,
             password=API_PUBLIC_PASSWORD):
     security = suds.wsse.Security()
     token = suds.wsse.UsernameToken(username, password)
     security.tokens.append(token)
     client = suds.client.Client(API_URL)
     client.set_options(wsse=security)
     self.client = client
コード例 #7
0
ファイル: client.py プロジェクト: jurismarches/python-payzen
    def _get_client(self):
        """
        Build a SOAP webservice client.

        /!\ Can be use only one time because the headers (and especially the
        request id) needs to be regenerated for each request
        """
        client = suds.client.Client(url=self._url)
        client.set_options(soapheaders=self._get_headers())
        return client
コード例 #8
0
def addSecurityHeader(client, username, password):
    # wsans = ('wsa', "http://www.w3.org/2005/08/addressing")
    security = Security()
    userNameToken = UsernameToken(username, password)
    timeStampToken = Timestamp(validity=600)
    # timeStampToken = Timestamp(validity=600)
    security.tokens.append(userNameToken)
    security.tokens.append(timeStampToken)
    # print(security.tokens)
    # action = client.service.sendBill.method.soap.action
    client.set_options(wsse=security)
コード例 #9
0
ファイル: bigsuds.py プロジェクト: sheltowt/bigsuds
def get_client(hostname, wsdl_name, username='******', password='******',
               cachedir=None, verify=False, timeout=90):
    """Returns and instance of suds.client.Client.

    A separate client is used for each iControl WSDL/Namespace (e.g.
    "LocalLB.Pool").

    This function allows any suds exceptions to propagate up to the caller.

    @param hostname: The IP address or hostname of the BIGIP.
    @param wsdl_name: The iControl namespace (e.g. "LocalLB.Pool")
    @param username: The admin username on the BIGIP.
    @param password: The admin password on the BIGIP.
    @param cachedir: The directory to cache wsdls in. None indicates
        that caching should be disabled.
    @param verify: When True, performs SSL certificate validation in
        Python / urllib2 versions that support it (v2.7.9 and newer)
    @param timeout: The time to wait (in seconds) before timing out
        the connection to the URL
    """
    url = 'https://%s/iControl/iControlPortal.cgi?WSDL=%s' % (
            hostname, wsdl_name)
    imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
    imp.filter.add('urn:iControl')

    if cachedir is not None:
        cachedir = ObjectCache(location=os.path.expanduser(cachedir), days=1)

    doctor = ImportDoctor(imp)
    if verify:
        client = Client(url, doctor=doctor, username=username, password=password,
                        cache=cachedir, timeout=timeout)
    else:
        transport = HTTPSTransportNoVerify(username=username,
                                           password=password, timeout=timeout)
        client = Client(url, doctor=doctor, username=username, password=password,
                        cache=cachedir, transport=transport, timeout=timeout)

    # Without this, subsequent requests will use the actual hostname of the
    # BIGIP, which is often times invalid.
    client.set_options(location=url.split('?')[0])
    client.factory.separator('_')
    return client
コード例 #10
0
ファイル: dfp.py プロジェクト: jdilallo/jdilallo-test
  def GetService(self, service_name, version=sorted(_SERVICE_MAP.keys())[-1],
                 server='https://www.google.com'):
    """Creates a service client for the given service.

    Args:
      service_name: A string identifying which DFP service to create a service
          client for.
      [optional]
      version: A string identifying the DFP version to connect to. This defaults
          to what is currently the latest version. This will be updated in
          future releases to point to what is then the latest version.
      server: A string identifying the webserver hosting the DFP API.

    Returns:
      A suds.client.ServiceSelector which has the headers and proxy configured
          for use.

    Raises:
      A GoogleAdsValueError if the service or version provided do not exist.
    """
    server = server[:-1] if server[-1] == '/' else server
    try:
      client = suds.client.Client(
          self._SOAP_SERVICE_FORMAT % (server, version, service_name),
          plugins=[googleads.common.Pruner()])
    except suds.transport.TransportError:
      if version in _SERVICE_MAP:
        if service_name in _SERVICE_MAP[version]:
          raise
        else:
          raise googleads.errors.GoogleAdsValueError(
              'Unrecognized service for the DFP API. Service given: %s '
              'Supported services: %s'
              % (service_name, _SERVICE_MAP[version]))
      else:
        raise googleads.errors.GoogleAdsValueError(
            'Unrecognized version of the DFP API. Version given: %s Supported '
            'versions: %s' % (version, _SERVICE_MAP.keys()))

    if self.https_proxy: client.set_options(proxy={'https': self.https_proxy})
    return googleads.common.SudsServiceProxy(client, self._header_handler)
コード例 #11
0
ファイル: bigsuds.py プロジェクト: TPLink32/spnk1
def get_client(hostname,
               wsdl_name,
               username='******',
               password='******',
               cachedir=None):
    """Returns and instance of suds.client.Client.

    A separate client is used for each iControl WSDL/Namespace (e.g.
    "LocalLB.Pool").

    This function allows any suds exceptions to propagate up to the caller.

    @param hostname: The IP address or hostname of the BIGIP.
    @param wsdl_name: The iControl namespace (e.g. "LocalLB.Pool")
    @param username: The admin username on the BIGIP.
    @param password: The admin password on the BIGIP.
    @param cachedir: The directory to cache wsdls in. None indicates
        that caching should be disabled.
    """
    url = 'https://%s/iControl/iControlPortal.cgi?WSDL=%s' % (hostname,
                                                              wsdl_name)
    imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
    imp.filter.add('urn:iControl')

    if cachedir is not None:
        cachedir = ObjectCache(location=os.path.expanduser(cachedir), days=1)

    doctor = ImportDoctor(imp)
    client = Client(url,
                    doctor=doctor,
                    username=username,
                    password=password,
                    cache=cachedir)

    # Without this, subsequent requests will use the actual hostname of the
    # BIGIP, which is often times invalid.
    client.set_options(location=url.split('?')[0])
    client.factory.separator('_')
    return client
コード例 #12
0
ファイル: xnnppx.py プロジェクト: schwarty/xnnppx
 def _call(self, 
           jws, 
           operation, 
           inputs, 
           authenticated=False, 
           fix_import=False):
     """perform a SOAP call"""
     url = '%s/axis/%s' % (self._base_url, jws)
     if authenticated:
         t = suds.transport.http.HttpAuthenticated(username=self._username, 
                                                   password=self._password)
     else:
         t = suds.transport.http.HttpTransport()
     if self._cookiejar is not None:
         t.cookiejar = self._cookiejar
     if fix_import:
         xsd_url = 'http://schemas.xmlsoap.org/soap/encoding/'
         imp = suds.xsd.doctor.Import(xsd_url)
         doctor = suds.xsd.doctor.ImportDoctor(imp)
         client = suds.client.Client('%s?wsdl' % url, 
                                     transport=t, 
                                     doctor=doctor)
     else:
         client = suds.client.Client('%s?wsdl' % url, transport=t)
     typed_inputs = []
     for (dtype, val) in inputs:
         ti = client.factory.create(dtype)
         ti.value = val
         typed_inputs.append(ti)
     # the WSDL returns the local IP address in the URLs; these need 
     # to be corrected if XNAT is behind a proxy
     client.set_options(location=url)
     f = getattr(client.service, operation)
     result = f(*typed_inputs)
     if self._cookiejar is None:
         self._cookiejar = t.cookiejar
     return result
コード例 #13
0
# import logging
# logging.basicConfig(level=logging.INFO)
# logging.getLogger('suds.client').setLevel(logging.DEBUG)
# logging.getLogger('suds.transport').setLevel(logging.DEBUG) # MUST BE THIS?
# logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
# logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
# logging.getLogger('suds.resolver').setLevel(logging.DEBUG)
# logging.getLogger('suds.xsd.query').setLevel(logging.DEBUG)
# logging.getLogger('suds.xsd.basic').setLevel(logging.DEBUG)
# logging.getLogger('suds.binding.marshaller').setLevel(logging.DEBUG)

# Fully credentialed service user with access to the Human Resources API
username = '******'
password = '******'

# wsdl url from public web services workday
# for more information refer documentation on workday on SOAP
wsdl_url = 'https://****************************/Staffing/v24.1?wsdl'
client = 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(username, password)
security.tokens.append(token)
client.set_options(wsse=security)
# The workflow is, generate an XML element containing the employee ID, then post
# that element to the Get_Workers() method in the WSDL as an argument.
# We could do this with two suds calls, having it generate the XML from the schema,
# but here I'm creating the POST XML manually and submitting it via suds's `Raw()` function.
コード例 #14
0
ファイル: bigsuds.py プロジェクト: jdubs/f5-cli
 def _create_client_wrapper(self, client, wsdl_name):
     client.set_options(headers=self._headers)
     return super(_BIGIPSession, self)._create_client_wrapper(client, wsdl_name)
コード例 #15
0
ファイル: watch_pp.py プロジェクト: theundefined/scripts
import sys
import timeit
import getopt
import csv
url="https://tt.poczta-polska.pl/Sledzenie/services/Sledzenie?wsdl"
username="******"
password="******"

def show_data(client,numer):
    spr=client.service.sprawdzPrzesylke(numer)
    if not spr.danePrzesylki:
        print "Brak przesylki %s" % (numer,)
        return
    for i in spr.danePrzesylki.zdarzenia[0]:
        print numer,i.czas, i.jednostka.nazwa, i.kod, i.nazwa

if len(sys.argv) > 1:
    numery=list(sys.argv[1:])
else:
    numery={
            'RQ260561184SG' : 'fasttech',
            }

security = suds.wsse.Security()
token = suds.wsse.UsernameToken(username,password)
security.tokens.append(token)
client=suds.client.Client(url)
client.set_options(wsse=security)
for numer in numery:
    show_data(client,numer)
コード例 #16
0
ファイル: soap.py プロジェクト: jkinred/psphere
def get_client(url):
    client = suds.client.Client(url + "/vimService.wsdl")
    client.set_options(location=url)
    return client
コード例 #17
0
ファイル: bigsuds.py プロジェクト: zachcalvert/bigsuds
 def _create_client_wrapper(self, client, wsdl_name):
     client.set_options(headers=self._headers)
     return super(_BIGIPSession,
                  self)._create_client_wrapper(client, wsdl_name)
コード例 #18
0
ファイル: soap.py プロジェクト: caesarshift/psphere
def get_client(url):
    client = suds.client.Client(url + "/vimService.wsdl")
    client.set_options(location=url)
    return client
コード例 #19
0
except OSError:
    print "Could not fetch Alert Details. " +  sys.exc_info()[0]
'''
#--------------------------------------------------------------------------------------------------------------------------
if varlocaldebugging == True:
    print "Connecting to:", varArborURL, " User: "******" WSDL: " + WSDLfile
try:
    t = suds.transport.https.HttpAuthenticated(username=varArborUser,
                                               password=varArborPasswd)
    t.handler = urllib2.HTTPDigestAuthHandler(t.pm)
    t.urlopener = urllib2.build_opener(t.handler)
    client = suds.client.Client(url='file:///' + WSDLfile,
                                location=varArborURL + '/soap/sp',
                                transport=t)
    client.set_options(
        service='PeakflowSPService', port='PeakflowSPPort', cachingpolicy=1
    )  # retxml=false, prettyxml=false   # https://jortel.fedorapeople.org/suds/doc/suds.options.Options-class.html
    ArborResultRAW = client.service.getDosAlertDetails(varArgumentReceieved)

    #ArborMitResultRAW = client.service.getMitigationStatisticsByIdXML(varArgumentReceieved)
    #print(ArborResultRAW)
except ValueError:
    print "Oops! Could not connect to Arbor. " + sys.exc_info()[0]
    sys.exit(0)
#--------------------------------------------------------------------------------------------------------
try:
    ArborResultJSON = props(ArborResultRAW)
    if varlocal_log_to_file:
        varAppendText = str("\nAlert ID: " + varArgumentReceieved + "\n")
        with open(varLogFile, "a") as myfile:
            myfile.write(varAppendText)