var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
var xml = new chilkat.Xml();
xml.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.EmitXmlDecl = false;
var soapRequestBody = xml.GetXml();
var endpoint = "http://tdl.integration.aws.fema.gov/IPAWS_CAPService/IPAWS";
var 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"var contentType = "text/xml";
var http = new chilkat.Http();
http.ClearHeaders();
http.SetRequestHeader("Content-Type",contentType);
http.SetRequestHeader("SOAPAction",soapAction);
// resp: HttpResponsevar resp = http.PostXml(endpoint,soapRequestBody,"utf-8");
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
console.log("Failed to send SOAP request.");
return;
}
// Get the XML response body.var responseXml = new chilkat.Xml();
resp.GetBodyXml(responseXml);
var statusCode = resp.StatusCode;
console.log("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) {
console.log(responseXml.GetXml());
return;
}
console.log(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 = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:identifier");
var sender = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:sender");
var sent = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:sent");
var status = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:status");
var msgType = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:msgType");
var source = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:source");
var scope = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:scope");
var restriction = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:restriction");
var addresses = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:addresses");
var code = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:code");
var note = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:note");
var references = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:references");
var incidents = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:incidents");
var language = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:language");
var category = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:category");
var v_event = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:event");
var responseType = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:responseType");
var urgency = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:urgency");
var severity = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:severity");
var certainty = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:certainty");
var audience = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:audience");
var valueName = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:valueName");
var value = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:value");
var effective = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:effective");
var onset = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:onset");
var expires = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:expires");
var senderName = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:senderName");
var headline = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:headline");
var description = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:description");
var instruction = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:instruction");
var web = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:web");
var 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");
var resourceDesc = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:resourceDesc");
var mimeType = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:mimeType");
var size = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:size");
var uri = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:uri");
var derefUri = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:derefUri");
var digest = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:digest");
var areaDesc = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:areaDesc");
var polygon = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:polygon");
var 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");
var altitude = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:altitude");
var ceiling = responseXml.GetChildContent("*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:ceiling");
}
chilkatExample();