From 59e0b675d916887ea47650ba506e06b6d0af6fec Mon Sep 17 00:00:00 2001 From: Vlado Date: Fri, 27 Mar 2026 07:09:58 +0100 Subject: [PATCH] notebookvb --- .gitignore | 4 +++- 01ReceptyTest.py | 35 ++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 529222a..67e42e4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ __pycache__/ *.pyo .idea/ Thumbs.db -*.pfx \ No newline at end of file +*.pfx +*.xml +*.iml \ No newline at end of file diff --git a/01ReceptyTest.py b/01ReceptyTest.py index e9075e9..eae0158 100644 --- a/01ReceptyTest.py +++ b/01ReceptyTest.py @@ -1,3 +1,5 @@ +import uuid +from datetime import datetime, timezone from requests import Session from requests_pkcs12 import Pkcs12Adapter from zeep import Client @@ -7,10 +9,18 @@ from zeep.transports import Transport PFX_FILE = "AMBSUKL214235369G_31DEC2024.pfx" PFX_PASSWORD = "Vlado7309208104++" -WSDL_TEST = "https://lekar-soap.test-erecept.sukl.cz/cuer/Lekar?wsdl" -WSDL_PROD = "https://lekar-soap.erecept.sukl.cz/cuer/Lekar?wsdl" +# HTTP Basic Auth (portál SÚKL) +API_USER = "buzalkav" +API_PASS = "jgbbeCJTTLstGW7" -WSDL_URL = WSDL_PROD # přepni na WSDL_TEST pro testovací prostředí +# Lokální WSDL soubory (ze složky Recept) +WSDL_LOCAL = r"C:\Users\vlado\Documents\Recept\WSDL_XSD\PRIORITNI_WEBOVE_SLUZBY\CUERLekar.wsdl" + +# Skutečné endpointy +ENDPOINT_PROD = "https://lekar-soap.erecept.sukl.cz/cuer/Lekar" +ENDPOINT_TEST = "https://lekar-soap.test-erecept.sukl.cz/cuer/Lekar" + +ENDPOINT = ENDPOINT_TEST # testovací prostředí def get_client(): @@ -19,8 +29,12 @@ def get_client(): pkcs12_filename=PFX_FILE, pkcs12_password=PFX_PASSWORD )) + sess.auth = (API_USER, API_PASS) transport = Transport(session=sess, timeout=30) - client = Client(wsdl=WSDL_URL, transport=transport) + # Načteme lokální WSDL, endpoint přepíšeme na skutečnou URL + client = Client(wsdl=WSDL_LOCAL, transport=transport) + # Přepis service endpoint adresy + client.service._binding_options["address"] = ENDPOINT return client @@ -36,16 +50,23 @@ def list_operations(client): def app_ping(client): - print("\n=== AppPing ===") + print(f"\n=== AppPing -> {ENDPOINT} ===") try: - resp = client.service.AppPing() + zprava = { + "ID_Zpravy": str(uuid.uuid4()), + "Verze": "201704B", + "Odeslano": datetime.now(timezone.utc), + "SW_Klienta": "TestRecept12" # přesně 12 znaků + } + resp = client.service.AppPing(Zprava=zprava) print(f"Response: {resp}") except Exception as e: print(f"Chyba: {e}") if __name__ == "__main__": - print(f"Připojuji se na: {WSDL_URL}") + print(f"Načítám WSDL: {WSDL_LOCAL}") + print(f"Endpoint: {ENDPOINT}") client = get_client() list_operations(client) app_ping(client)