AutoIt
AutoIt
Peoplevox SaveData
See more Peoplevox Examples
Demonstrates how to call the Peoplevox SaveData SOAP method. This example adds a new carrier (DHL) to the system.Chilkat AutoIt Downloads
Local $bSuccess = 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/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.
;
$oSbSoapXml = ObjCreate("Chilkat.StringBuilder")
$oSbSoapXml.Append("<?xml version=""1.0"" encoding=""utf-8""?>" & @CRLF)
$oSbSoapXml.Append("<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" xmlns:peop=""http://www.peoplevox.net/"">" & @CRLF)
$oSbSoapXml.Append(" <soap:Header>" & @CRLF)
$oSbSoapXml.Append(" <peop:UserSessionCredentials>" & @CRLF)
$oSbSoapXml.Append(" <peop:UserId>PEOPLEVOX_USER_ID</peop:UserId>" & @CRLF)
$oSbSoapXml.Append(" <peop:ClientId>PEOPLEVOX_CLIENT_ID</peop:ClientId>" & @CRLF)
$oSbSoapXml.Append(" <peop:SessionId>PEOPLEVOX_SESSION_ID</peop:SessionId>" & @CRLF)
$oSbSoapXml.Append(" </peop:UserSessionCredentials>" & @CRLF)
$oSbSoapXml.Append(" </soap:Header>" & @CRLF)
$oSbSoapXml.Append(" <soap:Body>" & @CRLF)
$oSbSoapXml.Append(" <peop:SaveData>" & @CRLF)
$oSbSoapXml.Append(" <peop:saveRequest>" & @CRLF)
$oSbSoapXml.Append(" <peop:TemplateName>Carriers</peop:TemplateName>" & @CRLF)
$oSbSoapXml.Append(" <peop:CsvData>CSV_DATA</peop:CsvData>" & @CRLF)
$oSbSoapXml.Append(" <peop:Action>0</peop:Action>" & @CRLF)
$oSbSoapXml.Append(" </peop:saveRequest>" & @CRLF)
$oSbSoapXml.Append(" </peop:SaveData>" & @CRLF)
$oSbSoapXml.Append(" </soap:Body>" & @CRLF)
$oSbSoapXml.Append("</soap:Envelope>")
$oSbCsvData = ObjCreate("Chilkat.StringBuilder")
$oSbCsvData.Append("Name,Reference" & @CRLF)
$oSbCsvData.Append("DHL,D0001")
Local $iNumReplacements = $oSbSoapXml.Replace("CSV_DATA",$oSbCsvData.GetAsString())
$oReq = ObjCreate("Chilkat.HttpRequest")
$oReq.HttpVerb = "POST"
$oReq.SendCharset = True
$oReq.Charset = "utf-8"
$oReq.AddHeader "Content-Type","text/xml"
$oReq.AddHeader "SOAPAction","http://www.peoplevox.net/SaveData"
$oReq.Path = "/PEOPLEVOX_CLIENT_ID/resources/integrationservicev4.asmx"
$bSuccess = $oReq.LoadBodyFromString($oSbSoapXml.GetAsString(),"utf-8")
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.FollowRedirects = True
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpSReq("qac.peoplevox.net",443,True,$oReq,$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
; We should expect a 200 response if successful.
If ($oResp.StatusCode <> 200) Then
ConsoleWrite("Response StatusCode = " & $oResp.StatusCode & @CRLF)
ConsoleWrite("Response StatusLine: " & $oResp.StatusLine & @CRLF)
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oResp.Header & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)
Exit
EndIf
$oXmlResponse = ObjCreate("Chilkat.Xml")
$bSuccess = $oXmlResponse.LoadXml($oResp.BodyStr)
ConsoleWrite($oXmlResponse.GetXml() & @CRLF)
; A successful response is shown below.
; To parse a successful response:
Local $sReference = $oXmlResponse.ChilkatPath("soap:Body|SaveDataResponse|SaveDataResult|Statuses|IntegrationStatusResponse|Reference|*")
ConsoleWrite("Reference = " & $sReference & @CRLF)
Local $status = $oXmlResponse.ChilkatPath("soap:Body|SaveDataResponse|SaveDataResult|Statuses|IntegrationStatusResponse|Status|*")
ConsoleWrite("Status = " & $status & @CRLF)
; <?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>