CAPSoapHttp / getMessage
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
#include <C_CkXmlW.h>
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkXmlW xml;
const wchar_t *soapRequestBody;
const wchar_t *endpoint;
const wchar_t *soapAction;
const wchar_t *contentType;
HCkHttpW http;
HCkHttpResponseW resp;
HCkXmlW responseXml;
int statusCode;
const wchar_t *identifier;
const wchar_t *sender;
const wchar_t *sent;
const wchar_t *status;
const wchar_t *msgType;
const wchar_t *source;
const wchar_t *scope;
const wchar_t *restriction;
const wchar_t *addresses;
const wchar_t *code;
const wchar_t *note;
const wchar_t *references;
const wchar_t *incidents;
const wchar_t *language;
const wchar_t *category;
const wchar_t *v_event;
const wchar_t *responseType;
const wchar_t *urgency;
const wchar_t *severity;
const wchar_t *certainty;
const wchar_t *audience;
const wchar_t *valueName;
const wchar_t *value;
const wchar_t *effective;
const wchar_t *onset;
const wchar_t *expires;
const wchar_t *senderName;
const wchar_t *headline;
const wchar_t *description;
const wchar_t *instruction;
const wchar_t *web;
const wchar_t *contact;
const wchar_t *resourceDesc;
const wchar_t *mimeType;
const wchar_t *size;
const wchar_t *uri;
const wchar_t *derefUri;
const wchar_t *digest;
const wchar_t *areaDesc;
const wchar_t *polygon;
const wchar_t *circle;
const wchar_t *altitude;
const wchar_t *ceiling;
xml = CkXmlW_Create();
CkXmlW_putTag(xml,L"soapenv:Envelope");
CkXmlW_AddAttribute(xml,L"xmlns:soapenv",L"http://schemas.xmlsoap.org/soap/envelope/");
CkXmlW_AddAttribute(xml,L"xmlns:req",L"http://gov.fema.ipaws.services/caprequest");
CkXmlW_AddAttribute(xml,L"xmlns:WL5G3N1",L"http://gov.fema.ipaws.services/IPAWS_CAPService/");
CkXmlW_AddAttribute(xml,L"xmlns:capreq",L"http://gov.fema.ipaws.services/caprequest");
CkXmlW_UpdateChildContent(xml,L"soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonUser",L"xml");
CkXmlW_UpdateChildContent(xml,L"soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonCogId",L"xml");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestAPI",L"string");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestOperation",L"string");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterName",L"string");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:comparisonOp",L"string");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterValue",L"string");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:logicalOp",L"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.
CkXmlW_putEmitXmlDecl(xml,FALSE);
soapRequestBody = CkXmlW_getXml(xml);
endpoint = L"http://tdl.integration.aws.fema.gov/IPAWS_CAPService/IPAWS";
soapAction = L"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 = L"text/xml";
http = CkHttpW_Create();
CkHttpW_ClearHeaders(http);
CkHttpW_SetRequestHeader(http,L"Content-Type",contentType);
CkHttpW_SetRequestHeader(http,L"SOAPAction",soapAction);
resp = CkHttpW_PostXml(http,endpoint,soapRequestBody,L"utf-8");
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
wprintf(L"Failed to send SOAP request.\n");
CkXmlW_Dispose(xml);
CkHttpW_Dispose(http);
return;
}
// Get the XML response body.
responseXml = CkXmlW_Create();
CkHttpResponseW_GetBodyXml(resp,responseXml);
statusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"response status code: %d\n",statusCode);
CkHttpResponseW_Dispose(resp);
// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.
if (statusCode != 200) {
wprintf(L"%s\n",CkXmlW_getXml(responseXml));
CkXmlW_Dispose(xml);
CkHttpW_Dispose(http);
CkXmlW_Dispose(responseXml);
return;
}
wprintf(L"%s\n",CkXmlW_getXml(responseXml));
// 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 = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:identifier");
sender = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:sender");
sent = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:sent");
status = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:status");
msgType = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:msgType");
source = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:source");
scope = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:scope");
restriction = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:restriction");
addresses = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:addresses");
code = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:code");
note = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:note");
references = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:references");
incidents = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:incidents");
language = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:language");
category = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:category");
v_event = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:event");
responseType = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:responseType");
urgency = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:urgency");
severity = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:severity");
certainty = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:certainty");
audience = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:audience");
valueName = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:valueName");
value = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:value");
effective = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:effective");
onset = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:onset");
expires = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:expires");
senderName = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:senderName");
headline = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:headline");
description = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:description");
instruction = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:instruction");
web = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:web");
contact = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:contact");
valueName = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:valueName");
value = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:value");
resourceDesc = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:resourceDesc");
mimeType = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:mimeType");
size = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:size");
uri = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:uri");
derefUri = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:derefUri");
digest = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:digest");
areaDesc = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:areaDesc");
polygon = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:polygon");
circle = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:circle");
valueName = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:valueName");
value = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:value");
altitude = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:altitude");
ceiling = CkXmlW_getChildContent(responseXml,L"*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:ceiling");
CkXmlW_Dispose(xml);
CkHttpW_Dispose(http);
CkXmlW_Dispose(responseXml);
}