CAPSoapHttp / postCAP
ASP AutoIt C C (Unicode) C++ C++ (Unicode) C# DataFlex Delphi Foxpro Go Java Node.js Objective-C Perl PHP Extension PowerBuilder Powershell PureBasic Python CkPython Ruby SQL Server Swift TCL VB.NET VB6 VBScript Xojo
func chilkatTest() {
let xml = CkoXml()!
xml.tag = "soapenv:Envelope"
xml.addAttribute("xmlns:soapenv", value: "http://schemas.xmlsoap.org/soap/envelope/")
xml.addAttribute("xmlns:WL5G3N1", value: "http://gov.fema.ipaws.services/IPAWS_CAPService/")
xml.addAttribute("xmlns:cap", value: "urn:oasis:names:tc:emergency:cap:1.2")
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:postCAPRequestTypeDef|cap:alert|cap:identifier", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:sender", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:sent", value: "dateTime")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:status", value: "Actual")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:msgType", value: "Alert")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:source", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:scope", value: "Public")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:restriction", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:addresses", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:code", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:note", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:references", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:incidents", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:language", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:category", value: "Geo")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:event", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:responseType", value: "Shelter")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:urgency", value: "Immediate")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:severity", value: "Extreme")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:certainty", value: "Observed")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:audience", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:eventCode|cap:valueName", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:eventCode|cap:value", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:effective", value: "dateTime")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:onset", value: "dateTime")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:expires", value: "dateTime")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:senderName", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:headline", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:description", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:instruction", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:web", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:contact", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:parameter|cap:valueName", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:parameter|cap:value", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:resource|cap:resourceDesc", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:resource|cap:mimeType", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:resource|cap:size", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:resource|cap:uri", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:resource|cap:derefUri", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:resource|cap:digest", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:area|cap:areaDesc", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:area|cap:polygon", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:area|cap:circle", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:area|cap:geocode|cap:valueName", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:area|cap:geocode|cap:value", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:area|cap:altitude", value: "xml")
xml.updateChildContent("soapenv:Body|WL5G3N1:postCAPRequestTypeDef|cap:alert|cap:info|cap:area|cap:ceiling", value: "xml")
// 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 = false
var 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/postCAP"
// 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)
let resp = CkoHttpResponse()!
ERROR: Undefined variable(success)
ERROR: Undefined variable(success)
if success == false {
print("\(http.lastErrorText!)")
print("Failed to send SOAP request.")
return
}
// Get the XML response body.
let responseXml = CkoXml()!
resp.getBody(responseXml)
var statusCode: Int = resp.statusCode.intValue
print("response status code: \(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()!)")
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 parameterName: String? = responseXml.getChildContent("*:Body|*:postCAPResponseTypeDef|*:parameterListItem|*:parameterName")
var parameterValue: String? = responseXml.getChildContent("*:Body|*:postCAPResponseTypeDef|*:parameterListItem|*:parameterValue")
var subParameterName: String? = responseXml.getChildContent("*:Body|*:postCAPResponseTypeDef|*:parameterListItem|*:subParaListItem|*:subParameterName")
var subParameterValue: String? = responseXml.getChildContent("*:Body|*:postCAPResponseTypeDef|*:parameterListItem|*:subParaListItem|*:subParameterValue")
var ResponseOperation: String? = responseXml.getChildContent("*:Body|*:postCAPResponseTypeDef|*:ResponseOperation")
var ResponseType: String? = responseXml.getChildContent("*:Body|*:postCAPResponseTypeDef|*:ResponseType")
}
Request XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:WL5G3N1="http://gov.fema.ipaws.services/IPAWS_CAPService/" xmlns:cap="urn:oasis:names:tc:emergency:cap:1.2">
<soapenv:Header>
<WL5G3N1:request_Header>
<WL5G3N1:logonUser>xml</WL5G3N1:logonUser>
<WL5G3N1:logonCogId>xml</WL5G3N1:logonCogId>
</WL5G3N1:request_Header>
</soapenv:Header>
<soapenv:Body>
<WL5G3N1:postCAPRequestTypeDef>
<cap:alert>
<cap:identifier>xml</cap:identifier>
<cap:sender>xml</cap:sender>
<cap:sent>dateTime</cap:sent>
<cap:status>Actual</cap:status>
<cap:msgType>Alert</cap:msgType>
<cap:source>xml</cap:source>
<cap:scope>Public</cap:scope>
<cap:restriction>xml</cap:restriction>
<cap:addresses>xml</cap:addresses>
<cap:code>xml</cap:code>
<cap:note>xml</cap:note>
<cap:references>xml</cap:references>
<cap:incidents>xml</cap:incidents>
<cap:info>
<cap:language>xml</cap:language>
<cap:category>Geo</cap:category>
<cap:event>xml</cap:event>
<cap:responseType>Shelter</cap:responseType>
<cap:urgency>Immediate</cap:urgency>
<cap:severity>Extreme</cap:severity>
<cap:certainty>Observed</cap:certainty>
<cap:audience>xml</cap:audience>
<cap:eventCode>
<cap:valueName>xml</cap:valueName>
<cap:value>xml</cap:value>
</cap:eventCode>
<cap:effective>dateTime</cap:effective>
<cap:onset>dateTime</cap:onset>
<cap:expires>dateTime</cap:expires>
<cap:senderName>xml</cap:senderName>
<cap:headline>xml</cap:headline>
<cap:description>xml</cap:description>
<cap:instruction>xml</cap:instruction>
<cap:web>xml</cap:web>
<cap:contact>xml</cap:contact>
<cap:parameter>
<cap:valueName>xml</cap:valueName>
<cap:value>xml</cap:value>
</cap:parameter>
<cap:resource>
<cap:resourceDesc>xml</cap:resourceDesc>
<cap:mimeType>xml</cap:mimeType>
<cap:size>xml</cap:size>
<cap:uri>xml</cap:uri>
<cap:derefUri>xml</cap:derefUri>
<cap:digest>xml</cap:digest>
</cap:resource>
<cap:area>
<cap:areaDesc>xml</cap:areaDesc>
<cap:polygon>xml</cap:polygon>
<cap:circle>xml</cap:circle>
<cap:geocode>
<cap:valueName>xml</cap:valueName>
<cap:value>xml</cap:value>
</cap:geocode>
<cap:altitude>xml</cap:altitude>
<cap:ceiling>xml</cap:ceiling>
</cap:area>
</cap:info>
</cap:alert>
</WL5G3N1:postCAPRequestTypeDef>
</soapenv:Body>
</soapenv:Envelope>
Response XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:resp="http://gov.fema.ipaws.services/capresponse" xmlns:WL5G3N1="http://gov.fema.ipaws.services/IPAWS_CAPService/" xmlns:capresp="http://gov.fema.ipaws.services/capresponse">
<soapenv:Header/>
<soapenv:Body>
<WL5G3N1:postCAPResponseTypeDef>
<resp:parameterListItem>
<resp:parameterName>string</resp:parameterName>
<resp:parameterValue>string</resp:parameterValue>
<resp:subParaListItem>
<resp:subParameterName>string</resp:subParameterName>
<resp:subParameterValue>string</resp:subParameterValue>
</resp:subParaListItem>
</resp:parameterListItem>
<resp:ResponseOperation>string</resp:ResponseOperation>
<resp:ResponseType>string</resp:ResponseType>
</WL5G3N1:postCAPResponseTypeDef>
</soapenv:Body>
</soapenv:Envelope>