func chilkatTest() {
let xml = CkoXml()
xml.Tag = "soapenv:Envelope"
xml.AddAttribute("xmlns:soapenv", value: "http://schemas.xmlsoap.org/soap/envelope/")
xml.AddAttribute("xmlns:req", value: "http://gov.fema.ipaws.services/caprequest")
xml.AddAttribute("xmlns:WL5G3N1", value: "http://gov.fema.ipaws.services/IPAWS_CAPService/")
xml.AddAttribute("xmlns:capreq", value: "http://gov.fema.ipaws.services/caprequest")
xml.UpdateChildContent("soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonUser", value: "xml")
xml.UpdateChildContent("soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonCogId", value: "xml")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestAPI", value: "string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestOperation", value: "string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterName", value: "string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:comparisonOp", value: "string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterValue", value: "string")
xml.UpdateChildContent("soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:logicalOp", value: "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.EmitXmlDecl = falsevar soapRequestBody: String? = xml.GetXml()
var endpoint: String? = "http://tdl.integration.aws.fema.gov/IPAWS_CAPService/IPAWS"var soapAction: String? = "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"var contentType: String? = "text/xml"let http = CkoHttp()
http.ClearHeaders()
http.SetRequestHeader("Content-Type", value: contentType)
http.SetRequestHeader("SOAPAction", value: soapAction)
var resp: CkoHttpResponse? = http.PostXml(endpoint, xmlDoc: soapRequestBody, charset: "utf-8")
if http.LastMethodSuccess == false {
print("\(http.LastErrorText)")
print("Failed to send SOAP request.")
return
}
// Get the XML response body.let responseXml = CkoXml()
resp!.GetBodyXml(responseXml)
var statusCode: Int = resp!.StatusCode.intValue
print("response status code: \(statusCode)")
resp = nil// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.if statusCode != 200 {
print("\(responseXml.GetXml())")
return
}
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).var identifier: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:identifier")
var sender: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:sender")
var sent: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:sent")
var status: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:status")
var msgType: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:msgType")
var source: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:source")
var scope: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:scope")
var restriction: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:restriction")
var addresses: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:addresses")
var code: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:code")
var note: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:note")
var references: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:references")
var incidents: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:incidents")
var language: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:language")
var category: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:category")
var v_event: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:event")
var responseType: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:responseType")
var urgency: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:urgency")
var severity: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:severity")
var certainty: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:certainty")
var audience: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:audience")
var valueName: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:valueName")
var value: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:value")
var effective: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:effective")
var onset: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:onset")
var expires: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:expires")
var senderName: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:senderName")
var headline: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:headline")
var description: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:description")
var instruction: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:instruction")
var web: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:web")
var contact: String? = 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")
var resourceDesc: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:resourceDesc")
var mimeType: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:mimeType")
var size: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:size")
var uri: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:uri")
var derefUri: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:derefUri")
var digest: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:digest")
var areaDesc: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:areaDesc")
var polygon: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:polygon")
var circle: String? = 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")
var altitude: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:altitude")
var ceiling: String? = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:ceiling")
}