#include <CkXmlW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
CkXmlW xml;
xml.put_Tag(L"soap:Envelope");
xml.AddAttribute(L"xmlns:soap",L"http://www.w3.org/2003/05/soap-envelope");
xml.AddAttribute(L"xmlns:spr",L"http://www.springcm.com/atlas/webservices/v201308/scm/");
xml.UpdateChildContent(L"soap:Header",L"");
xml.UpdateChildContent(L"soap:Body|spr:ContactFind|spr:token",L"string");
xml.UpdateChildContent(L"soap:Body|spr:ContactFind|spr:SearchText",L"string");
xml.UpdateChildContent(L"soap:Body|spr:ContactFind|spr:IncludeDeleted",L"true");
// 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://soapna11.springcm.com/atlas/webservices/v201308/springcmservice.asmx";
const wchar_t *soapAction = L"http://www.springcm.com/atlas/webservices/v201308/scm/ContactFind";
// 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).const wchar_t *Id = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Id");
const wchar_t *Name = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Name");
const wchar_t *ObjectType = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:ObjectType");
const wchar_t *v_Email = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Email");
const wchar_t *FirstName = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:FirstName");
const wchar_t *LastName = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:LastName");
const wchar_t *PhoneNumber = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:PhoneNumber");
const wchar_t *FaxNumber = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:FaxNumber");
const wchar_t *Company = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Company");
const wchar_t *Department = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Department");
const wchar_t *Title = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Title");
const wchar_t *Address1 = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address1");
const wchar_t *Address2 = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address2");
const wchar_t *Address3 = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address3");
const wchar_t *City = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:City");
const wchar_t *ProvinceState = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:ProvinceState");
const wchar_t *PostalCode = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:PostalCode");
const wchar_t *Country = responseXml.getChildContent(L"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Country");
}