An add-on for Plone
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
- SOAP requests are cached (lifetime can be specified)
- Live-View to test your SOAP requests:
test_soap
: https://raw.githubusercontent.com/mbarde/unikold.connector/master/docs/connector.gif - Specific queries (
LSFQuery
,LSFSearchQuery
) to easily connect to products of HIS eG via their SOAP API (dbinterface
)
Installation
- Add
unikold.connector
to your buildout - Install via
prefs_install_products_form
- 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
- Set path to this folder in
@@unikold-connector-controlpanel
- 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
- Matthias Barde, mbarde@uni-koblenz.de
Changelog
1.0a1 (unreleased)
- Initial release. [mbarde]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for unikold.connector-1.0a2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e8a75937ef09d66d54e5d08ceb501b317dcd12e2adbf902da0858043656ab55 |
|
MD5 | 39f48ea7772624a2374b27bf3a0ab2ad |
|
BLAKE2b-256 | eb0012fc0ce172c4319b5e7d5fd680bcee379a6d379dec878a104dfe83316dcd |