open-MaStR icon indicating copy to clipboard operation
open-MaStR copied to clipboard

`GetMarktakteur` not part of `soap_api.download.MaStRAPI`

Open FlorianK13 opened this issue 1 year ago • 2 comments

The API call GetMarktakteur, as described here cannot be called using the python wrapper.

FlorianK13 avatar Jan 05 '24 15:01 FlorianK13

@chrwm Do you understand why this is the case?

FlorianK13 avatar Jan 08 '24 08:01 FlorianK13

The error it throws is 'MaStRAPI' has no attribute GetMarktakteur

FlorianK13 avatar Jan 08 '24 12:01 FlorianK13

I have the same problem did you find a workaround?

maxcave avatar Aug 17 '24 20:08 maxcave

I shortly checked the following:

  • We do bindings to the download class here. I checked the wsl file that is used and there is an operation GetMarktakteur

Unfortunately I have no time within the next weeks to dig deeper. I can investigate this later or maybe @nesnoj has some time?

FlorianK13 avatar Aug 19 '24 07:08 FlorianK13

I have tried a workaround using zeep on my own. This is probably a bit trivial for you @FlorianK13 but could prove useful if someone is looking to access any functions not yet implemented here.

from zeep import Client
wsdl_url = 'https://www.marktstammdatenregister.de/MaStRAPI/wsdl/mastr.wsdl'
apiKey = '4fil24gnio2gno24g2...' # example add your own here
marktakteurMastrNummer = 'SNB91234567890' # example add your "username" here

client = Client(wsdl_url)
client_bind = client.bind('Marktstammdatenregister', 'Akteur')
result = client_bind.GetMarktAkteur(
    apiKey=apiKey, 
    marktakteurMastrNummer=marktakteurMastrNummer, 
    mastrNummer='SNB91234567890') # Final argument is the Akteurnummer your are requesting
print(result)

I personally still have the issue that my apiKey does not have the writes to access any but suppose that is not an implementation problem.

If you want to adapt this to other functions then you change the 'Akteur' in client.bind() to the heading under which your function is featured in the documentation and the operation you call in the following line.

maxcave avatar Aug 19 '24 20:08 maxcave

Hey @maxcave,

I digged a bit and it worked out: With zeep I wasn't able to get any data ("ValueError: second must be in 0..59"), cf. #10. But with the own MaStRAPI it worked like a charm (the timing error is suppressed here)...ok, almost like a charm:

As you already state for the service

If you want to adapt this to other functions then you change the 'Akteur' in client.bind() to the heading under which your function is featured in the documentation and the operation you call in the following line.

you have to change it in open-MaStR's code as well here as it is hard-coded :thinking:. After setting it to service_port="Akteur" the function GetMarktakteur is available (you'll probably need to install from source to change..).

Working snippet:

from open_mastr.soap_api.download import MaStRAPI

apiKey = "..."   # your own key
marktakteurMastrNummer = "..."   # your own Marktakteur ID
mastr_api = MaStRAPI(user=marktakteurMastrNummer, key=apiKey)
mastr_api.GetMarktakteur(mastrNummer="SNB941690671609")  # should return data from E.DIS Netz GmbH

# Result:
# {'Ergebniscode': 'OK', 'AufrufVeraltet': False, 'AufrufLebenszeitEnde': None, 'AufrufVersion': 1, 'MastrNummer': 'SNB941690671609', ....

I personally still have the issue that my apiKey does not have the writes to access any but suppose that is not an implementation problem.

I used my personal key which has no advanced permissions..

Does this solution work at your end @maxcave?

We should remove this hard-coded "service_port" and allow to pass it as parameter. I will create a separate issue.

nesnoj avatar Aug 27 '24 14:08 nesnoj

As #557 has been merged, you can now just use branch develop and instantiate MaStRAPI(user, key, service_port="Akteur")

nesnoj avatar Aug 28 '24 15:08 nesnoj

Has been fixed, I will close.. Please reopen if necessary @maxcave

nesnoj avatar Sep 02 '24 11:09 nesnoj