Skip to main content

Plone addon for making persistent SOAP requests

Project description

unikold.connector

Plone-Addon for making persistent SOAP requests using a fast and modern Python SOAP client: zeep.

Requests are automatically stored as SOAPQuery objects which allows caching with variable lifetime of the responses.

Features

Installation

  1. Add unikold.connector to your buildout
  2. Install via prefs_install_products_form
  3. Create a SOAPQueriesFolder
  • For security reasons SOAPQueriesFolder are not globally addable by default - to be able to add it you need to allow adding this content type at the desired location temporarily
  • In this folder all queries will be stored
  • Maybe you also want to exclude it from navigation
  1. Set path to this folder in @@unikold-connector-controlpanel
  2. If you want to make use of LSF-Queries you also have to define settings in @@unikold-connector-lsf-controlpanel

Examples

After installing this addon you can make SOAP requests like this:

from unikold.connector.soap import SOAPConnector
soapConnector = SOAPConnector(
    'http://webservices.daehosting.com/services/isbnservice.wso?WSDL',  # URL to WSDL file
    'IsValidISBN13',                                                    # name of the method
    '9783492700764',                                                    # method parameter
    24                                                                  # lifetime of this request in hours
)
response = soapConnector.get()

If the request already exists and its lifetime did not expire soapConnector simply returns the stored response. If the request exists but is outdated it will be updated before returning the response. If the request does not yet exist, a new object will be created. Its path will be {SOAP-Queries-Folder}.{WSDL-URL}.{Methodname}.{Parameter} (where {SOAP-Queries-Folder} has to be specified in the controlpanel of this addon - otherwise a folder will be created at your sites' root).

To get the corresponding query object:

queryObject = soapConnector.getQuery()

Above example without this addon would look like this (remember no persistent objects, no caching):

from zeep import Client
url = 'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'
client = Client(url)
response = client.service.IsValidISBN13('9783492700764')

Automate updating of queries

Use Zope clock server to call unikold.connector.update (user must have permission cmf.ManagePortal):

[client2]
zope-conf-additional =
    <clock-server>
       method /SiteName/unikold.connector.update
       period 2880
       user username
       password *****
       host hostname.com
    </clock-server>

Parameters explained in detail here: https://docs.plone.org/develop/plone/misc/asyncronoustasks.html#clock-server

Updating big amounts of queries can take a while so its advisable to run the task on a dedicated client.

Testing

Before you can run the tests you need to create a file called config.py in the tests folder, containing following constants:

# -*- coding: utf-8 -*-
soap_test_url = u'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'
soap_test_method = u'IsValidISBN13'
soap_test_method_parameter = u'9783492700764'

# config data needed for LSF tests
lsf_wsdl_url = u''  # URL to LSF WSDL file containing getDataXML method
lsf_test_object_type = u''  # LSF object type
lsf_test_conditions = []  # a list of tuples, i.e. [('prename', 'Peter')]
lsf_wsdl_search_url = u''  #  URL to LSF search WSDL
lsf_search_test_method_parameter = u''  # XML-formatted parameter for the search method

# for testing LSF methods with authentication
lsf_auth_username = u''
lsf_auth_password = u''
lsf_auth_test_object_type = u''  # LSF object type
lsf_auth_test_conditions_0 = []  # a list of tuples, i.e. [('prename', 'Peter')]
lsf_auth_test_conditions_1 = []  # a list of tuples, i.e. [('prename', 'Peter')]
  • bin/test
  • bin/code-analysis

TypeError: string indices must be integers

Make sure this fix has been applied to zeep: https://github.com/mvantellingen/python-zeep/pull/657/commits/a2b7ec0296bcb0ac47a5d15669dcb769447820eb

License

The project is licensed under the GPLv2.

Contributors

Changelog

1.0a1 (unreleased)

  • Initial release. [mbarde]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unikold.connector-1.0a3.tar.gz (297.0 kB view hashes)

Uploaded Source

Built Distribution

unikold.connector-1.0a3-py2.py3-none-any.whl (58.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page