Banque Carrefour de la Sécurité Sociale

Heute starten mit dem Projekt “Anbindung an die BCSS”.

Die BCSS ist eine belgische nationale Datenbank, in der persönliche Daten zur sozialen Sicherheit gespeichert sind. Der Zugang ist streng geregelt und gut abgesichert, aber jedes normale ÖSHZ hat einen Zugang dazu.

Ausgangspunkt ist eine Serie von 10 Dokumenten, die man hier runterladen kann.


Ich habe daraufhin wsdl2py gefunden, das ein Teil von ZSI ist.

Hier zwei erste Beispiele (angepasst aus der Doku von ZSI)


# based on Examples in http://pywebsvcs.sourceforge.net/zsi.html

def hello():
    return "Hello, world"

def echo(*args):
    return args

def average(*args):
    print args
    sum = 0
    for i in args: sum += i
    return sum / len(args)

from ZSI import dispatch


from ZSI.client import Binding
fp = open('debug.out', 'a')
#~ b = Binding(url='/cgi-bin/simple-test', tracefile=fp)
b = Binding(url='', tracefile=fp)
a = b.average(range(1,11))
assert a == 5
print b.hello()

N.B.: die letzte releaste Version 2.0 funktioniert nicht mit neueren Python-Versionen. Aber ZSI-2.1-a1.tar.gz wohl.

One problem with the ZSI documentation is that the examples there don’t work anymore because the respective servers have disappeared or modified their service.

Through www.xmethods.net I found the countries service by www.mobilefish.com which seems to work.

wsdl2py http://www.mobilefish.com/services/web_service/countries.php?wsdl

This created ndeed the 3 files countries_webservice_mobilefish_com_client.py, xxx_server.py and xxx_types.py. But even now I didn’t manage to get an example request to work. Here is where I abandoned:

# import the generated class stubs
import countries_webservice_mobilefish_com_client as client
import countries_webservice_mobilefish_com_server as server
# get a port proxy instance
loc = client.countries_webservice_mobilefish_comServiceLocator()
#~ addr = loc.getcountries_webservice_mobilefish_comPortAddress()
port = loc.getcountries_webservice_mobilefish_comPort()
# create a new request
req = server.countryInfoByIanaRequest(ianacode='be')
#~ req.Options = req.new_Options()
#~ req.Options.Query = ’newton’
# call the remote method
resp = port.WolframSearch(req)
# print results
print ’Search Time:’, resp.Result.SearchTime
print ’Total Matches:’, resp.Result.TotalMatches
for hit in resp.Result.Matches.Item:
print ’--’, hit.Title


I discovered that Dive Into Python has a chapter on SOAP.

Only a few minor problems:

  • SOAPpy caused a traceback “SyntaxError: from __future__ imports must occur at the beginning of the file” in Python 2.7, but that was easy to fix, and only 3 files were concerned.
  • Oops, the example in DIP is also obsolete: Google says “We are no longer issuing new API keys for the SOAP Search API.” http://code.google.com/intl/de/apis/soapsearch/api_faq.html#price1

But it wasn’t difficult to write my own script inspect_wsdl.py:


  python inspect_wsdl.py <URL>

Where <URL> must return the WSDL of a web service. Examples:

Thanks to http://diveintopython.org/soap_web_services/"""
import sys
from SOAPpy import WSDL

def inspect(wsdl_url):
    print wsdl_url
    proxy = WSDL.Proxy(wsdl_url)
    #~ proxy.soapproxy.config.dumpSOAPOut = 1
    #~ proxy.soapproxy.config.dumpSOAPIn = 1
    for k,v in proxy.methods.items():
        print '%s(%s)' % (k,','.join([(p.type[1]+' '+p.name) for p in v.inparams]))
        print '  --> ' + ','.join([(p.type[1]+' '+p.name) for p in v.outparams])
    #~ print proxy.countryInfoByIana('be')

if __name__ == '__main__':
    if len(sys.argv) <= 1:
          print __doc__
    for url in sys.argv[1:]:

If I call it like this:

python inspect_wsdl.py http://www.mobilefish.com/services/web_service/countries.php?wsdl

Then the output is:

countryInfoByIana(string ianacode)
  --> CountryData countryinfo
  --> IANAList ianalist
regionsInfoByIana(string ianacode)
  --> RegionList regionlist
<SOAPpy.Types.structType return at 15857024>: {'countryname': 'Belgium', 'latitude': 50.503887, 'longitude': 4.469936, '  ianacode': 'be'}

Inspecting the BCSS

Launching inspect_wsdl.py on a BCSS server, I get only one method:

sendXML(xmlString requestXML)
  --> xmlString replyXML

… which is of course not very instructive per se

Next step will be to get the XSDs to be used for requestXML and replyXML.