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
var
xml: HCkXml;
soapRequestBody: PWideChar;
endpoint: PWideChar;
soapAction: PWideChar;
contentType: PWideChar;
http: HCkHttp;
resp: HCkHttpResponse;
responseXml: HCkXml;
statusCode: Integer;
identifier: PWideChar;
sender: PWideChar;
sent: PWideChar;
status: PWideChar;
msgType: PWideChar;
source: PWideChar;
scope: PWideChar;
restriction: PWideChar;
addresses: PWideChar;
code: PWideChar;
note: PWideChar;
references: PWideChar;
incidents: PWideChar;
language: PWideChar;
category: PWideChar;
v_event: PWideChar;
responseType: PWideChar;
urgency: PWideChar;
severity: PWideChar;
certainty: PWideChar;
audience: PWideChar;
valueName: PWideChar;
value: PWideChar;
effective: PWideChar;
onset: PWideChar;
expires: PWideChar;
senderName: PWideChar;
headline: PWideChar;
description: PWideChar;
instruction: PWideChar;
web: PWideChar;
contact: PWideChar;
resourceDesc: PWideChar;
mimeType: PWideChar;
size: PWideChar;
uri: PWideChar;
derefUri: PWideChar;
digest: PWideChar;
areaDesc: PWideChar;
polygon: PWideChar;
circle: PWideChar;
altitude: PWideChar;
ceiling: PWideChar;
begin
xml := CkXml_Create();
CkXml_putTag(xml,'soapenv:Envelope');
CkXml_AddAttribute(xml,'xmlns:soapenv','http://schemas.xmlsoap.org/soap/envelope/');
CkXml_AddAttribute(xml,'xmlns:req','http://gov.fema.ipaws.services/caprequest');
CkXml_AddAttribute(xml,'xmlns:WL5G3N1','http://gov.fema.ipaws.services/IPAWS_CAPService/');
CkXml_AddAttribute(xml,'xmlns:capreq','http://gov.fema.ipaws.services/caprequest');
CkXml_UpdateChildContent(xml,'soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonUser','xml');
CkXml_UpdateChildContent(xml,'soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonCogId','xml');
CkXml_UpdateChildContent(xml,'soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestAPI','string');
CkXml_UpdateChildContent(xml,'soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestOperation','string');
CkXml_UpdateChildContent(xml,'soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterName','string');
CkXml_UpdateChildContent(xml,'soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:comparisonOp','string');
CkXml_UpdateChildContent(xml,'soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterValue','string');
CkXml_UpdateChildContent(xml,'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.
CkXml_putEmitXmlDecl(xml,False);
soapRequestBody := CkXml__getXml(xml);
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 := CkHttp_Create();
CkHttp_ClearHeaders(http);
CkHttp_SetRequestHeader(http,'Content-Type',contentType);
CkHttp_SetRequestHeader(http,'SOAPAction',soapAction);
resp := CkHttp_PostXml(http,endpoint,soapRequestBody,'utf-8');
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Memo1.Lines.Add('Failed to send SOAP request.');
Exit;
end;
// Get the XML response body.
responseXml := CkXml_Create();
CkHttpResponse_GetBodyXml(resp,responseXml);
statusCode := CkHttpResponse_getStatusCode(resp);
Memo1.Lines.Add('response status code: ' + IntToStr(statusCode));
CkHttpResponse_Dispose(resp);
// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.
if (statusCode <> 200) then
begin
Memo1.Lines.Add(CkXml__getXml(responseXml));
Exit;
end;
Memo1.Lines.Add(CkXml__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 := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:identifier');
sender := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:sender');
sent := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:sent');
status := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:status');
msgType := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:msgType');
source := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:source');
scope := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:scope');
restriction := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:restriction');
addresses := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:addresses');
code := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:code');
note := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:note');
references := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:references');
incidents := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:incidents');
language := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:language');
category := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:category');
v_event := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:event');
responseType := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:responseType');
urgency := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:urgency');
severity := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:severity');
certainty := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:certainty');
audience := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:audience');
valueName := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:valueName');
value := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:value');
effective := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:effective');
onset := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:onset');
expires := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:expires');
senderName := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:senderName');
headline := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:headline');
description := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:description');
instruction := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:instruction');
web := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:web');
contact := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:contact');
valueName := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:valueName');
value := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:value');
resourceDesc := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:resourceDesc');
mimeType := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:mimeType');
size := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:size');
uri := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:uri');
derefUri := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:derefUri');
digest := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:digest');
areaDesc := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:areaDesc');
polygon := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:polygon');
circle := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:circle');
valueName := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:valueName');
value := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:value');
altitude := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:altitude');
ceiling := CkXml__getChildContent(responseXml,'*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:ceiling');
CkXml_Dispose(xml);
CkHttp_Dispose(http);
CkXml_Dispose(responseXml);