PowerBuilder
PowerBuilder
Peoplevox WMS Authentication
See more HTTP Examples
Provides an example of a call to the Peoplevox WMS Authenticate using SOAP 1.1.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_SbSoapXml
oleobject loo_Crypt
string ls_PasswordBase64
integer li_NumReplacements
oleobject loo_Req
oleobject loo_Http
oleobject loo_Resp
oleobject loo_XmlResponse
string ls_Detail
li_Success = 0
// 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>
//
loo_SbSoapXml = create oleobject
li_rc = loo_SbSoapXml.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
destroy loo_SbSoapXml
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_SbSoapXml.Append("<?xml version=~"1.0~" encoding=~"utf-8~"?>")
loo_SbSoapXml.Append("<soapenv:Envelope xmlns:soapenv=~"http://schemas.xmlsoap.org/soap/envelope/~" xmlns:peop=~"http://www.peoplevox.net/~">")
loo_SbSoapXml.Append(" <soapenv:Header/>")
loo_SbSoapXml.Append(" <soapenv:Body>")
loo_SbSoapXml.Append(" <peop:Authenticate>")
loo_SbSoapXml.Append(" <peop:clientId>PEOPLEVOX_CLIENT_ID</peop:clientId>")
loo_SbSoapXml.Append(" <peop:username>PEOPLEVOX_USERNAME</peop:username>")
loo_SbSoapXml.Append(" <peop:password>PEOPLEVOX_BASE64_PASSWORD</peop:password>")
loo_SbSoapXml.Append(" </peop:Authenticate>")
loo_SbSoapXml.Append(" </soapenv:Body>")
loo_SbSoapXml.Append("</soapenv:Envelope>")
// Base64 encode the password and update the SOAP XML.
loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")
ls_PasswordBase64 = loo_Crypt.EncodeString("PEOPLEVOX_PASSWORD","utf-8","base64")
li_NumReplacements = loo_SbSoapXml.Replace("PEOPLEVOX_BASE64_PASSWORD",ls_PasswordBase64)
loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")
loo_Req.HttpVerb = "POST"
loo_Req.SendCharset = 1
loo_Req.Charset = "utf-8"
loo_Req.AddHeader("Content-Type","text/xml")
loo_Req.AddHeader("SOAPAction","http://www.peoplevox.net/Authenticate")
loo_Req.Path = "/PEOPLEVOX_CLIENT_ID/resources/integrationservicev4.asmx"
li_Success = loo_Req.LoadBodyFromString(loo_SbSoapXml.GetAsString(),"utf-8")
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
loo_Http.FollowRedirects = 1
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpSReq("qac.peoplevox.net",443,1,loo_Req,loo_Resp)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_SbSoapXml
destroy loo_Crypt
destroy loo_Req
destroy loo_Http
destroy loo_Resp
return
end if
// We should expect a 200 response if successful.
if loo_Resp.StatusCode <> 200 then
Write-Debug "Response StatusCode = " + string(loo_Resp.StatusCode)
Write-Debug "Response StatusLine: " + loo_Resp.StatusLine
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
destroy loo_SbSoapXml
destroy loo_Crypt
destroy loo_Req
destroy loo_Http
destroy loo_Resp
return
end if
// 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>
//
loo_XmlResponse = create oleobject
li_rc = loo_XmlResponse.ConnectToNewObject("Chilkat.Xml")
li_Success = loo_XmlResponse.LoadXml(loo_Resp.BodyStr)
Write-Debug loo_XmlResponse.GetXml()
// Show how to get the Detail, which must be the ClientId,SessionId
ls_Detail = loo_XmlResponse.ChilkatPath("soap:Body|AuthenticateResponse|AuthenticateResult|Detail|*")
Write-Debug "Detail = " + ls_Detail
destroy loo_SbSoapXml
destroy loo_Crypt
destroy loo_Req
destroy loo_Http
destroy loo_Resp
destroy loo_XmlResponse