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 WMS AuthenticationProvides an example of a call to the Peoplevox WMS Authenticate using SOAP 1.1.
IncludeFile "CkHttp.pb" IncludeFile "CkXml.pb" IncludeFile "CkCrypt2.pb" IncludeFile "CkHttpRequest.pb" IncludeFile "CkHttpResponse.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/Authenticate ; Content-Length: (automatically computed and added by Chilkat) ; Host: qac.peoplevox.net ; ; <?xml version="1.0" encoding="utf-8"?> ; <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:peop="http://www.peoplevox.net/"> ; <soapenv:Header/> ; <soapenv:Body> ; <peop:Authenticate> ; <peop:clientId>PEOPLEVOX_CLIENT_ID</peop:clientId> ; <peop:username>PEOPLEVOX_USERNAME</peop:username> ; <peop:password>PEOPLEVOX_BASE64_PASSWORD</peop:password> ; </peop:Authenticate> ; </soapenv:Body> ; </soapenv:Envelope> ; 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) + "?>") CkStringBuilder::ckAppend(sbSoapXml,"<soapenv:Envelope xmlns:soapenv=" + Chr(34) + "http://schemas.xmlsoap.org/soap/envelope/" + Chr(34) + " xmlns:peop=" + Chr(34) + "http://www.peoplevox.net/" + Chr(34) + ">") CkStringBuilder::ckAppend(sbSoapXml," <soapenv:Header/>") CkStringBuilder::ckAppend(sbSoapXml," <soapenv:Body>") CkStringBuilder::ckAppend(sbSoapXml," <peop:Authenticate>") CkStringBuilder::ckAppend(sbSoapXml," <peop:clientId>PEOPLEVOX_CLIENT_ID</peop:clientId>") CkStringBuilder::ckAppend(sbSoapXml," <peop:username>PEOPLEVOX_USERNAME</peop:username>") CkStringBuilder::ckAppend(sbSoapXml," <peop:password>PEOPLEVOX_BASE64_PASSWORD</peop:password>") CkStringBuilder::ckAppend(sbSoapXml," </peop:Authenticate>") CkStringBuilder::ckAppend(sbSoapXml," </soapenv:Body>") CkStringBuilder::ckAppend(sbSoapXml,"</soapenv:Envelope>") ; Base64 encode the password and update the SOAP XML. crypt.i = CkCrypt2::ckCreate() If crypt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf passwordBase64.s = CkCrypt2::ckEncodeString(crypt,"PEOPLEVOX_PASSWORD","utf-8","base64") numReplacements.i = CkStringBuilder::ckReplace(sbSoapXml,"PEOPLEVOX_BASE64_PASSWORD",passwordBase64) 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/Authenticate") 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) CkCrypt2::ckDispose(crypt) 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) CkStringBuilder::ckDispose(sbSoapXml) CkCrypt2::ckDispose(crypt) CkHttpRequest::ckDispose(req) CkHttp::ckDispose(http) ProcedureReturn EndIf ; A successful response returns this XML: ; <?xml version="1.0" encoding="utf-8" ?> ; <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> ; <soap:Body> ; <AuthenticateResponse xmlns="http://www.peoplevox.net/"> ; <AuthenticateResult> ; <ResponseId>0</ResponseId> ; <TotalCount>1</TotalCount> ; <Detail>PEOPLEVOX_CLIENT_ID,7fe13431-c67f-4d52-bcfd-b60fbfa3b0ca</Detail> ; <Statuses /> ; <ImportingQueueId>0</ImportingQueueId> ; <SalesOrdersToDespatchIds /> ; </AuthenticateResult> ; </AuthenticateResponse> ; </soap:Body> ; </soap:Envelope> ; 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) ; Show how to get the Detail, which must be the ClientId,SessionId detail.s = CkXml::ckChilkatPath(xmlResponse,"soap:Body|AuthenticateResponse|AuthenticateResult|Detail|*") Debug "Detail = " + detail CkStringBuilder::ckDispose(sbSoapXml) CkCrypt2::ckDispose(crypt) CkHttpRequest::ckDispose(req) CkHttp::ckDispose(http) CkXml::ckDispose(xmlResponse) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.