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 SaveDataDemonstrates how to call the Peoplevox SaveData SOAP method. This example adds a new carrier (DHL) to the system.
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkXml.pb" IncludeFile "CkHttpRequest.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/SaveData ; 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:SaveData> ; <peop:saveRequest> ; <peop:TemplateName>Carriers</peop:TemplateName> ; <peop:CsvData>CSV_DATA</peop:CsvData> ; <peop:Action>0</peop:Action> ; </peop:saveRequest> ; </peop:SaveData> ; </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:SaveData>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:saveRequest>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:TemplateName>Carriers</peop:TemplateName>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:CsvData>CSV_DATA</peop:CsvData>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," <peop:Action>0</peop:Action>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </peop:saveRequest>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </peop:SaveData>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml," </soap:Body>" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbSoapXml,"</soap:Envelope>") sbCsvData.i = CkStringBuilder::ckCreate() If sbCsvData.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbCsvData,"Name,Reference" + Chr(13) + Chr(10)) CkStringBuilder::ckAppend(sbCsvData,"DHL,D0001") numReplacements.i = CkStringBuilder::ckReplace(sbSoapXml,"CSV_DATA",CkStringBuilder::ckGetAsString(sbCsvData)) 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/SaveData") 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) CkStringBuilder::ckDispose(sbCsvData) 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) CkStringBuilder::ckDispose(sbCsvData) 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) ; A successful response is shown below. ; To parse a successful response: reference.s = CkXml::ckChilkatPath(xmlResponse,"soap:Body|SaveDataResponse|SaveDataResult|Statuses|IntegrationStatusResponse|Reference|*") Debug "Reference = " + reference status.s = CkXml::ckChilkatPath(xmlResponse,"soap:Body|SaveDataResponse|SaveDataResult|Statuses|IntegrationStatusResponse|Status|*") Debug "Status = " + status ; <?xml version="1.0" encoding="utf-8" ?> ; <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> ; <soap:Body> ; <SaveDataResponse xmlns="http://www.peoplevox.net/"> ; <SaveDataResult> ; <ResponseId>0</ResponseId> ; <TotalCount>1</TotalCount> ; <Detail /> ; <Statuses> ; <IntegrationStatusResponse> ; <Reference>D0001</Reference> ; <Status>Success</Status> ; <LineNo>0</LineNo> ; </IntegrationStatusResponse> ; </Statuses> ; <ImportingQueueId>0</ImportingQueueId> ; <SalesOrdersToDespatchIds /> ; </SaveDataResult> ; </SaveDataResponse> ; </soap:Body> ; </soap:Envelope> CkStringBuilder::ckDispose(sbSoapXml) CkStringBuilder::ckDispose(sbCsvData) CkHttpRequest::ckDispose(req) CkHttp::ckDispose(http) CkXml::ckDispose(xmlResponse) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.