#include <CkXmlW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
CkXmlW xml;
xml.put_Tag(L"soapenv:Envelope");
xml.AddAttribute(L"xmlns:soapenv",L"http://schemas.xmlsoap.org/soap/envelope/");
xml.AddAttribute(L"xmlns:tra",L"http://training.gov.au/services/12/");
xml.AddAttribute(L"xmlns:arr",L"http://schemas.microsoft.com/2003/10/Serialization/Arrays");
xml.UpdateChildContent(L"soapenv:Header",L"");
xml.UpdateChildContentInt(L"soapenv:Body|tra:Search|tra:request|tra:PageNumber",1042);
xml.UpdateChildContentInt(L"soapenv:Body|tra:Search|tra:request|tra:PageSize",1042);
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:ClassificationFilters|tra:ClassificationFilter|tra:Scheme",L"string");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:ClassificationFilters|tra:ClassificationFilter|tra:Values|arr:string",L"string");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:CurrentNamesOnly",L"true");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:ExcludeNotRtos",L"true");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:ExcludeRtoWithoutActiveRegistration",L"true");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:Filter",L"string");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:IncludeCode",L"true");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:IncludeLegacyData",L"true");
xml.UpdateChildContent(L"soapenv:Body|tra:Search|tra:request|tra:RegistrationManagers|arr:string",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.
xml.put_EmitXmlDecl(false);
const wchar_t *soapRequestBody = xml.getXml();
const wchar_t *endpoint = L"https://ws.staging.training.gov.au/Deewr.Tga.WebServices/OrganisationServiceV12.svc/Organisation";
const wchar_t *soapAction = L"http://training.gov.au/services/12/IOrganisationService/Search";
// For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"const wchar_t *contentType = L"text/xml";
CkHttpW http;
http.ClearHeaders();
http.SetRequestHeader(L"Content-Type",contentType);
http.SetRequestHeader(L"SOAPAction",soapAction);
CkHttpResponseW *resp = http.PostXml(endpoint,soapRequestBody,L"utf-8");
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
wprintf(L"Failed to send SOAP request.\n");
return;
}
// Get the XML response body.CkXmlW responseXml;
resp->GetBodyXml(responseXml);
int statusCode = resp->get_StatusCode();
wprintf(L"response status code: %d\n",statusCode);
delete 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",responseXml.getXml());
return;
}
wprintf(L"%s\n",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).int Count = responseXml.GetChildIntValue(L"*:Body|*:SearchResponse|*:SearchResult|*:Count");
int PageNumber = responseXml.GetChildIntValue(L"*:Body|*:SearchResponse|*:SearchResult|*:PageNumber");
int PageSize = responseXml.GetChildIntValue(L"*:Body|*:SearchResponse|*:SearchResult|*:PageSize");
const wchar_t *Code = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:Code");
const wchar_t *DataManagerCode = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:DataManagerCode");
const wchar_t *HasActiveRegistration = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:HasActiveRegistration");
const wchar_t *IsLegacyData = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:IsLegacyData");
const wchar_t *LegalPersonName = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:LegalPersonName");
const wchar_t *RegistrationStatus = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:RegistrationStatus");
const wchar_t *TradingName = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:TradingName");
const wchar_t *DateTime = responseXml.getChildContent(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:UpdatedDate|*:DateTime");
int OffsetMinutes = responseXml.GetChildIntValue(L"*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:UpdatedDate|*:OffsetMinutes");
}