#include <C_CkXml.h>
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkXml xml;
const char *soapRequestBody;
const char *endpoint;
const char *soapAction;
const char *contentType;
HCkHttp http;
HCkHttpResponse resp;
HCkXml responseXml;
int statusCode;
const char *Id;
const char *Name;
const char *ObjectType;
const char *v_Email;
const char *FirstName;
const char *LastName;
const char *PhoneNumber;
const char *FaxNumber;
const char *Company;
const char *Department;
const char *Title;
const char *Address1;
const char *Address2;
const char *Address3;
const char *City;
const char *ProvinceState;
const char *PostalCode;
const char *Country;
xml = CkXml_Create();
CkXml_putTag(xml,"soap:Envelope");
CkXml_AddAttribute(xml,"xmlns:soap","http://www.w3.org/2003/05/soap-envelope");
CkXml_AddAttribute(xml,"xmlns:spr","http://www.springcm.com/atlas/webservices/v201308/scm/");
CkXml_UpdateChildContent(xml,"soap:Header","");
CkXml_UpdateChildContent(xml,"soap:Body|spr:ContactFind|spr:token","string");
CkXml_UpdateChildContent(xml,"soap:Body|spr:ContactFind|spr:SearchText","string");
CkXml_UpdateChildContent(xml,"soap:Body|spr:ContactFind|spr:IncludeDeleted","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. CkXml_putEmitXmlDecl(xml,FALSE);
soapRequestBody = CkXml_getXml(xml);
endpoint = "https://soapna11.springcm.com/atlas/webservices/v201308/springcmservice.asmx";
soapAction = "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"
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) {
printf("%s\n",CkHttp_lastErrorText(http));
printf("Failed to send SOAP request.\n");
CkXml_Dispose(xml);
CkHttp_Dispose(http);
return;
}
// Get the XML response body.
responseXml = CkXml_Create();
CkHttpResponse_GetBodyXml(resp,responseXml);
statusCode = CkHttpResponse_getStatusCode(resp);
printf("response status code: %d\n",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) {
printf("%s\n",CkXml_getXml(responseXml));
CkXml_Dispose(xml);
CkHttp_Dispose(http);
CkXml_Dispose(responseXml);
return;
}
printf("%s\n",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).
Id = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Id");
Name = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Name");
ObjectType = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:ObjectType");
v_Email = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Email");
FirstName = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:FirstName");
LastName = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:LastName");
PhoneNumber = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:PhoneNumber");
FaxNumber = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:FaxNumber");
Company = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Company");
Department = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Department");
Title = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Title");
Address1 = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address1");
Address2 = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address2");
Address3 = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Address3");
City = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:City");
ProvinceState = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:ProvinceState");
PostalCode = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:PostalCode");
Country = CkXml_getChildContent(responseXml,"*:Body|*:ContactFindResponse|*:ContactFindResult|*:SCMContactInfo|*:Country");
CkXml_Dispose(xml);
CkHttp_Dispose(http);
CkXml_Dispose(responseXml);
}