Unicode C++
Unicode C++
Peoplevox GetReportData
See more Peoplevox Examples
Demonstrates how to export data from a Peoplevox Warehouse Management System (WMS) using a system report template.Chilkat Unicode C++ Downloads
#include <CkStringBuilderW.h>
#include <CkHttpRequestW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
#include <CkXmlW.h>
#include <CkCsvW.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Sends a POST that looks like this:
// POST /PEOPLEVOX_CLIENT_ID/resources/integrationservicev4.asmx HTTP/1.1
// Content-Type: text/xml;charset=UTF-8
// SOAPAction: http://www.peoplevox.net/GetReportData
// Content-Length: (automatically computed and added by Chilkat)
// Host: qac.peoplevox.net
//
// <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:peop="http://www.peoplevox.net/">
// <soap:Header>
// <peop:UserSessionCredentials>
// <peop:UserId>PEOPLEVOX_USER_ID</peop:UserId>
// <peop:ClientId>PEOPLEVOX_CLIENT_ID</peop:ClientId>
// <peop:SessionId>PEOPLEVOX_SESSION_ID</peop:SessionId>
// </peop:UserSessionCredentials>
// </soap:Header>
// <soap:Body>
// <peop:GetReportData>
// <peop:getReportRequest>
// <peop:TemplateName>Item movement history</peop:TemplateName>
// <peop:PageNo>1</peop:PageNo>
// <peop:ItemsPerPage>20</peop:ItemsPerPage>
// <peop:OrderBy>[Date timestamp]</peop:OrderBy>
// <peop:Columns>[Item code],[Date timestamp],[From],[To],[Quantity],[Comments]</peop:Columns>
// <peop:SearchClause>([Date timestamp] > DateTime(2016,01,01,09,00,00))</peop:SearchClause>
// </peop:getReportRequest>
// </peop:GetReportData>
// </soap:Body>
// </soap:Envelope>
//
// Notice that a UserId is needed here. This is different than the username required for Peoplevox authentication.
// The UserId for the admin account is 1.
//
CkStringBuilderW sbSoapXml;
sbSoapXml.Append(L"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
sbSoapXml.Append(L"<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:peop=\"http://www.peoplevox.net/\">\r\n");
sbSoapXml.Append(L" <soap:Header>\r\n");
sbSoapXml.Append(L" <peop:UserSessionCredentials>\r\n");
sbSoapXml.Append(L" <peop:UserId>PEOPLEVOX_USER_ID</peop:UserId>\r\n");
sbSoapXml.Append(L" <peop:ClientId>PEOPLEVOX_CLIENT_ID</peop:ClientId>\r\n");
sbSoapXml.Append(L" <peop:SessionId>PEOPLEVOX_SESSION_ID</peop:SessionId>\r\n");
sbSoapXml.Append(L" </peop:UserSessionCredentials>\r\n");
sbSoapXml.Append(L" </soap:Header>\r\n");
sbSoapXml.Append(L" <soap:Body>\r\n");
sbSoapXml.Append(L" <peop:GetReportData>\r\n");
sbSoapXml.Append(L" <peop:getReportRequest>\r\n");
sbSoapXml.Append(L" <peop:TemplateName>Item movement history</peop:TemplateName>\r\n");
sbSoapXml.Append(L" <peop:PageNo>1</peop:PageNo>\r\n");
sbSoapXml.Append(L" <peop:ItemsPerPage>20</peop:ItemsPerPage>\r\n");
sbSoapXml.Append(L" <peop:OrderBy>[Date timestamp]</peop:OrderBy>\r\n");
sbSoapXml.Append(L" <peop:Columns>[Item code],[Date timestamp],[From],[To],[Quantity],[Comments]</peop:Columns>\r\n");
sbSoapXml.Append(L" <peop:SearchClause>([Date timestamp] > DateTime(2016,01,01,09,00,00))</peop:SearchClause>\r\n");
sbSoapXml.Append(L" </peop:getReportRequest>\r\n");
sbSoapXml.Append(L" </peop:GetReportData>\r\n");
sbSoapXml.Append(L" </soap:Body>\r\n");
sbSoapXml.Append(L"</soap:Envelope>");
CkHttpRequestW req;
req.put_HttpVerb(L"POST");
req.put_SendCharset(true);
req.put_Charset(L"utf-8");
req.AddHeader(L"Content-Type",L"text/xml");
req.AddHeader(L"SOAPAction",L"http://www.peoplevox.net/GetReportData");
req.put_Path(L"/PEOPLEVOX_CLIENT_ID/resources/integrationservicev4.asmx");
success = req.LoadBodyFromString(sbSoapXml.getAsString(),L"utf-8");
CkHttpW http;
http.put_FollowRedirects(true);
CkHttpResponseW resp;
success = http.HttpSReq(L"qac.peoplevox.net",443,true,req,resp);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
// We should expect a 200 response if successful.
if (resp.get_StatusCode() != 200) {
wprintf(L"Response StatusCode = %d\n",resp.get_StatusCode());
wprintf(L"Response StatusLine: %s\n",resp.statusLine());
wprintf(L"Response Header:\n");
wprintf(L"%s\n",resp.header());
wprintf(L"%s\n",resp.bodyStr());
return;
}
CkXmlW xmlResponse;
success = xmlResponse.LoadXml(resp.bodyStr());
wprintf(L"%s\n",xmlResponse.getXml());
const wchar_t *detail = xmlResponse.chilkatPath(L"soap:Body|GetReportDataResponse|GetReportDataResult|Detail|*");
CkCsvW csv;
csv.put_HasColumnNames(true);
csv.LoadFromString(detail);
wprintf(L"NumRows = %d\n",csv.get_NumRows());
wprintf(L"NumColumns = %d\n",csv.get_NumColumns());
// Iterate over the rows, getting the ItemCode, Name, and Barcode
int i = 0;
int numRows = csv.get_NumRows();
while (i < numRows) {
wprintf(L"Item code: %s\n",csv.getCellByName(i,L"Item code"));
wprintf(L"Date timestamp: %s\n",csv.getCellByName(i,L"Date timestamp"));
wprintf(L"From: %s\n",csv.getCellByName(i,L"From"));
wprintf(L"To: %s\n",csv.getCellByName(i,L"To"));
wprintf(L"Quantity: %s\n",csv.getCellByName(i,L"Quantity"));
wprintf(L"Comments: %s\n",csv.getCellByName(i,L"Comments"));
wprintf(L"-\n");
i = i + 1;
}
}