notebookvb
This commit is contained in:
+28
-7
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user