Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Peoplevox GetReportDataDemonstrates how to export data from a Peoplevox Warehouse Management System (WMS) using a system report template.
IncludeFile "CkHttp.pb" IncludeFile "CkXml.pb" IncludeFile "CkHttpRequest.pb" IncludeFile "CkHttpResponse.pb" IncludeFile "CkCsv.pb" IncludeFile "CkStringBuilder.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. success.i ; 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. ; sbSoapXml.i = CkStringBuilder::ckCreate() If sbSoapXml.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbSoapXml,"<?xml version=" + Chr(34) + "1.0" + Chr(34) + " encoding=" + Chr(34) + "utf-8" + Chr(34) + "?>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml,"<soap:Envelope xmlns:soap=" + Chr(34) + "http://www.w3.org/2003/05/soap-envelope" + Chr(34) + " xmlns:peop=" + Chr(34) + "http://www.peoplevox.net/" + Chr(34) + ">" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <soap:Header>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:UserSessionCredentials>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:UserId>PEOPLEVOX_USER_ID</peop:UserId>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:ClientId>PEOPLEVOX_CLIENT_ID</peop:ClientId>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:SessionId>PEOPLEVOX_SESSION_ID</peop:SessionId>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </peop:UserSessionCredentials>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </soap:Header>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <soap:Body>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:GetReportData>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:getReportRequest>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:TemplateName>Item movement history</peop:TemplateName>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:PageNo>1</peop:PageNo>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:ItemsPerPage>20</peop:ItemsPerPage>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:OrderBy>[Date timestamp]</peop:OrderBy>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:Columns>[Item code],[Date timestamp],[From],[To],[Quantity],[Comments]</peop:Columns>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:SearchClause>([Date timestamp] > DateTime(2016,01,01,09,00,00))</peop:SearchClause>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </peop:getReportRequest>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </peop:GetReportData>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </soap:Body>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml,"</soap:Envelope>") req.i = CkHttpRequest::ckCreate() If req.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttpRequest::setCkHttpVerb(req, "POST") CkHttpRequest::setCkSendCharset(req, 1) CkHttpRequest::setCkCharset(req, "utf-8") CkHttpRequest::ckAddHeader(req,"Content-Type","text/xml") CkHttpRequest::ckAddHeader(req,"SOAPAction","http://www.peoplevox.net/GetReportData") CkHttpRequest::setCkPath(req, "/PEOPLEVOX_CLIENT_ID/resources/integrationservicev4.asmx") success = CkHttpRequest::ckLoadBodyFromString(req,CkStringBuilder::ckGetAsString(sbSoapXml),"utf-8") http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttp::setCkFollowRedirects(http, 1) resp.i = CkHttp::ckSynchronousRequest(http,"qac.peoplevox.net",443,1,req) If CkHttp::ckLastMethodSuccess(http) <> 1 Debug CkHttp::ckLastErrorText(http) CkStringBuilder::ckDispose(sbSoapXml) CkHttpRequest::ckDispose(req) CkHttp::ckDispose(http) ProcedureReturn EndIf ; We should expect a 200 response if successful. If CkHttpResponse::ckStatusCode(resp) <> 200 Debug "Response StatusCode = " + Str(CkHttpResponse::ckStatusCode(resp)) Debug "Response StatusLine: " + CkHttpResponse::ckStatusLine(resp) Debug "Response Header:" Debug CkHttpResponse::ckHeader(resp) Debug CkHttpResponse::ckBodyStr(resp) CkStringBuilder::ckDispose(sbSoapXml) CkHttpRequest::ckDispose(req) CkHttp::ckDispose(http) ProcedureReturn EndIf xmlResponse.i = CkXml::ckCreate() If xmlResponse.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkXml::ckLoadXml(xmlResponse,CkHttpResponse::ckBodyStr(resp)) Debug CkXml::ckGetXml(xmlResponse) CkHttpResponse::ckDispose(resp) detail.s = CkXml::ckChilkatPath(xmlResponse,"soap:Body|GetReportDataResponse|GetReportDataResult|Detail|*") csv.i = CkCsv::ckCreate() If csv.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkCsv::setCkHasColumnNames(csv, 1) CkCsv::ckLoadFromString(csv,detail) Debug "NumRows = " + Str(CkCsv::ckNumRows(csv)) Debug "NumColumns = " + Str(CkCsv::ckNumColumns(csv)) ; Iterate over the rows, getting the ItemCode, Name, and Barcode i.i = 0 numRows.i = CkCsv::ckNumRows(csv) While i < numRows Debug "Item code: " + CkCsv::ckGetCellByName(csv,i,"Item code") Debug "Date timestamp: " + CkCsv::ckGetCellByName(csv,i,"Date timestamp") Debug "From: " + CkCsv::ckGetCellByName(csv,i,"From") Debug "To: " + CkCsv::ckGetCellByName(csv,i,"To") Debug "Quantity: " + CkCsv::ckGetCellByName(csv,i,"Quantity") Debug "Comments: " + CkCsv::ckGetCellByName(csv,i,"Comments") Debug "-" i = i + 1 Wend CkStringBuilder::ckDispose(sbSoapXml) CkHttpRequest::ckDispose(req) CkHttp::ckDispose(http) CkXml::ckDispose(xmlResponse) CkCsv::ckDispose(csv) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.