import sys
import chilkat
xml = chilkat.CkXml()
xml.put_Tag("soapenv:Envelope")
xml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
xml.AddAttribute("xmlns:req","http://gov.fema.ipaws.services/caprequest")
xml.AddAttribute("xmlns:WL5G3N1","http://gov.fema.ipaws.services/IPAWS_CAPService/")
xml.AddAttribute("xmlns:capreq","http://gov.fema.ipaws.services/caprequest")
xml.UpdateChildContent("soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonUser","xml")
xml.UpdateChildContent("soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonCogId","xml")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestAPI","string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestOperation","string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterName","string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:comparisonOp","string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterValue","string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:logicalOp","string")
# In a SOAP HTTP request, including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the XML body is generally not required.
xml.put_EmitXmlDecl(False)
soapRequestBody = xml.getXml()
endpoint = "http://tdl.integration.aws.fema.gov/IPAWS_CAPService/IPAWS"
soapAction = "http://gov.fema.ipaws.services/IPAWS_CAPService/getMessage"# For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
contentType = "text/xml"
http = chilkat.CkHttp()
http.ClearHeaders()
http.SetRequestHeader("Content-Type",contentType)
http.SetRequestHeader("SOAPAction",soapAction)
# resp is a CkHttpResponse
resp = http.PostXml(endpoint,soapRequestBody,"utf-8")
if (http.get_LastMethodSuccess() == False):
print(http.lastErrorText())
print("Failed to send SOAP request.")
sys.exit()
# Get the XML response body.
responseXml = chilkat.CkXml()
resp.GetBodyXml(responseXml)
statusCode = resp.get_StatusCode()
print("response status code: " + str(statusCode))
# If the status code does not indicate succcess, then show the response XML,
# which probably contains error information.if (statusCode != 200):
print(responseXml.getXml())
sys.exit()
print(responseXml.getXml())
# Parse the successful SOAP response XML.# This is a sample of the response XML, but the namespace prefixes will be different.
# We can parse the result using "*" for the namespace prefixes (see below).
identifier = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:identifier")
sender = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:sender")
sent = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:sent")
status = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:status")
msgType = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:msgType")
source = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:source")
scope = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:scope")
restriction = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:restriction")
addresses = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:addresses")
code = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:code")
note = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:note")
references = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:references")
incidents = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:incidents")
language = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:language")
category = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:category")
v_event = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:event")
responseType = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:responseType")
urgency = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:urgency")
severity = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:severity")
certainty = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:certainty")
audience = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:audience")
valueName = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:valueName")
value = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:value")
effective = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:effective")
onset = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:onset")
expires = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:expires")
senderName = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:senderName")
headline = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:headline")
description = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:description")
instruction = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:instruction")
web = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:web")
contact = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:contact")
valueName = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:valueName")
value = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:value")
resourceDesc = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:resourceDesc")
mimeType = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:mimeType")
size = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:size")
uri = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:uri")
derefUri = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:derefUri")
digest = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:digest")
areaDesc = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:areaDesc")
polygon = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:polygon")
circle = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:circle")
valueName = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:valueName")
value = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:value")
altitude = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:altitude")
ceiling = responseXml.getChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:ceiling")