Sample code for 30+ languages & platforms
Delphi DLL

Peoplevox WMS Authentication

See more HTTP Examples

Provides an example of a call to the Peoplevox WMS Authenticate using SOAP 1.1.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, HttpResponse, HttpRequest, StringBuilder, Xml, Crypt2;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
sbSoapXml: HCkStringBuilder;
crypt: HCkCrypt2;
passwordBase64: PWideChar;
numReplacements: Integer;
req: HCkHttpRequest;
http: HCkHttp;
resp: HCkHttpResponse;
xmlResponse: HCkXml;
detail: PWideChar;

begin
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/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 := CkStringBuilder_Create();
CkStringBuilder_Append(sbSoapXml,'<?xml version="1.0" encoding="utf-8"?>');
CkStringBuilder_Append(sbSoapXml,'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:peop="http://www.peoplevox.net/">');
CkStringBuilder_Append(sbSoapXml,'   <soapenv:Header/>');
CkStringBuilder_Append(sbSoapXml,'   <soapenv:Body>');
CkStringBuilder_Append(sbSoapXml,'      <peop:Authenticate>');
CkStringBuilder_Append(sbSoapXml,'         <peop:clientId>PEOPLEVOX_CLIENT_ID</peop:clientId>');
CkStringBuilder_Append(sbSoapXml,'         <peop:username>PEOPLEVOX_USERNAME</peop:username>');
CkStringBuilder_Append(sbSoapXml,'         <peop:password>PEOPLEVOX_BASE64_PASSWORD</peop:password>');
CkStringBuilder_Append(sbSoapXml,'      </peop:Authenticate>');
CkStringBuilder_Append(sbSoapXml,'   </soapenv:Body>');
CkStringBuilder_Append(sbSoapXml,'</soapenv:Envelope>');

// Base64 encode the password and update the SOAP XML.
crypt := CkCrypt2_Create();
passwordBase64 := CkCrypt2__encodeString(crypt,'PEOPLEVOX_PASSWORD','utf-8','base64');
numReplacements := CkStringBuilder_Replace(sbSoapXml,'PEOPLEVOX_BASE64_PASSWORD',passwordBase64);

req := CkHttpRequest_Create();
CkHttpRequest_putHttpVerb(req,'POST');
CkHttpRequest_putSendCharset(req,True);
CkHttpRequest_putCharset(req,'utf-8');
CkHttpRequest_AddHeader(req,'Content-Type','text/xml');
CkHttpRequest_AddHeader(req,'SOAPAction','http://www.peoplevox.net/Authenticate');
CkHttpRequest_putPath(req,'/PEOPLEVOX_CLIENT_ID/resources/integrationservicev4.asmx');
success := CkHttpRequest_LoadBodyFromString(req,CkStringBuilder__getAsString(sbSoapXml),'utf-8');

http := CkHttp_Create();
CkHttp_putFollowRedirects(http,True);

resp := CkHttpResponse_Create();
success := CkHttp_HttpSReq(http,'qac.peoplevox.net',443,True,req,resp);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

// We should expect a 200 response if successful.
if (CkHttpResponse_getStatusCode(resp) <> 200) then
  begin
    Memo1.Lines.Add('Response StatusCode = ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
    Memo1.Lines.Add('Response StatusLine: ' + CkHttpResponse__statusLine(resp));
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkHttpResponse__header(resp));
    Exit;
  end;

// 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 := CkXml_Create();
success := CkXml_LoadXml(xmlResponse,CkHttpResponse__bodyStr(resp));
Memo1.Lines.Add(CkXml__getXml(xmlResponse));

// Show how to get the Detail, which must be the ClientId,SessionId
detail := CkXml__chilkatPath(xmlResponse,'soap:Body|AuthenticateResponse|AuthenticateResult|Detail|*');
Memo1.Lines.Add('Detail = ' + detail);

CkStringBuilder_Dispose(sbSoapXml);
CkCrypt2_Dispose(crypt);
CkHttpRequest_Dispose(req);
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
CkXml_Dispose(xmlResponse);

end;