Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 3 working example. #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions cir.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!python
#!/usr/bin/python
"""
CIR python example
"""

import logging
import random
import string
import ConfigParser
import configparser
import os.path
import sys

from suds import MethodNotFound
# from suds import MethodNotFound
from suds.client import Client
from suds.wsse import Security, UsernameToken
from suds.sax.element import Element
Expand All @@ -20,15 +23,20 @@
MUST_UNDERSTAND = Attribute('SOAP-ENV:mustUnderstand', 'true')

if not os.path.isfile('credentials.ini'):
print 'First create or request credentials at:\nhttp://www.rechtspraak.nl/Uitspraken-en-Registers/centraal-insolventieregister/Pages/Aanvraag-Autorisatie.aspx'

msg = ('First create or request credentials at',
':\nhttps://www.rechtspraak.nl/Uitspraken-en-Registers/centraal-insolventieregister/Pages/Aanvraag-Autorisatie.aspx'
)
print(msg)
sys.exit(-1)

Config = ConfigParser.ConfigParser()
Config = configparser.ConfigParser()
Config.read("credentials.ini")

USERNAME = Config.get('Login', 'Username')
PASSWORD = Config.get('Login', 'Password')


def main():
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
Expand All @@ -38,21 +46,26 @@ def main():
add_security(client, USERNAME, PASSWORD)
add_addressing(client, WEBSERVICE_URL)

# client.service.GetLastUpdate()
# method = client.service.GetLastUpdate()
# method = client.service.searchModifiedSince("2021-05-01T00:00:00")
# client.service.searchByDate("2014-07-14T00:00:00", "01", "Uitspraken faillissement")

method = get_method(client, 'GetLastUpdate')
# 2021-05-31
# method = client.service.searchModifiedSince("2021-05-30T00:00:00")

print(method())

print method()

def add_security(client, user, passwd):
sec = Security()
token = UsernameToken(user, passwd)
token.setnonce()
token.setcreated()
# token.setcreated()
sec.tokens.append(token)
client.set_options(wsse=sec)


def add_addressing(client, webservice_url):
headers = []

Expand All @@ -66,19 +79,22 @@ def add_addressing(client, webservice_url):

client.set_options(soapheaders=headers)


def get_method(client, method):
try:
m = getattr(client.service, method)
action = client.wsdl.services[0].ports[0].methods[method].soap.action
action = action.replace('"', '')
except MethodNotFound:
except(Exception):
print(Exception)
return None

action_header = Element('Action', ns=NS_WSA).setText(action)
client.options.soapheaders.append(action_header)

return m


def generate_messageid():
fmt = 'xxxxxxxx-xxxxx'
resp = ''
Expand All @@ -93,4 +109,3 @@ def generate_messageid():

if __name__ == '__main__':
main()

5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
suds
configparser==5.0.2
jedi==0.18.0
parso==0.8.2
suds-py3==1.4.4.1