#!/usr/bin/env python3
"""Test SOAP endpoint accessibility"""
import requests
import urllib3
urllib3.disable_warnings()

BASE = "https://localhost:5000"

# Test SOAP WSDL access
print("[*] Testing SOAP WSDL endpoint...")
try:
    r = requests.get(f"{BASE}/examples/soap_examples/call/soap?WSDL", verify=False, allow_redirects=False)
    print(f"    Status: {r.status_code}")
    if r.status_code == 200:
        print(f"    ✓ SOAP service is accessible!")
        print(f"    WSDL preview: {r.text[:500]}")
except Exception as e:
    print(f"    Error: {e}")

# Test SOAP call
print("\n[*] Testing SOAP method call...")
soap_request = """<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <AddIntegers>
      <a>5</a>
      <b>3</b>
    </AddIntegers>
  </soap:Body>
</soap:Envelope>"""

try:
    r = requests.post(f"{BASE}/examples/soap_examples/call/soap", 
                     data=soap_request,
                     headers={"Content-Type": "text/xml; charset=utf-8",
                             "SOAPAction": "AddIntegers"},
                     verify=False)
    print(f"    Status: {r.status_code}")
    print(f"    Response: {r.text[:500]}")
except Exception as e:
    print(f"    Error: {e}")
