Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

C Web API Examples

Primary Categories

CardConnect
Facebook
GeoOp
Jira
PayPal
Peoplevox
QuickBooks

Shopify
Stripe
SugarCRM
Twitter
VoiceBase
Walmart
Xero
eBay
effectconnect

 

 

 

(C) Peoplevox WMS Authentication

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

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Win Mobile 5.0/Pocket PC 2003

Solaris C/C++

FreeBSD C/C++

OpenBSD C/C++

MinGW C/C++

#include <C_CkStringBuilder.h>
#include <C_CkCrypt2.h>
#include <C_CkHttpRequest.h>
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
#include <C_CkXml.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkStringBuilder sbSoapXml;
    HCkCrypt2 crypt;
    const char *passwordBase64;
    int numReplacements;
    HCkHttpRequest req;
    HCkHttp http;
    HCkHttpResponse resp;
    HCkXml xmlResponse;
    const char *detail;

    // 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 = CkHttp_SynchronousRequest(http,"qac.peoplevox.net",443,TRUE,req);
    if (CkHttp_getLastMethodSuccess(http) != TRUE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkStringBuilder_Dispose(sbSoapXml);
        CkCrypt2_Dispose(crypt);
        CkHttpRequest_Dispose(req);
        CkHttp_Dispose(http);
        return;
    }

    // We should expect a 200 response if successful.
    if (CkHttpResponse_getStatusCode(resp) != 200) {
        printf("Response StatusCode = %d\n",CkHttpResponse_getStatusCode(resp));
        printf("Response StatusLine: %s\n",CkHttpResponse_statusLine(resp));
        printf("Response Header:\n");
        printf("%s\n",CkHttpResponse_header(resp));
        CkStringBuilder_Dispose(sbSoapXml);
        CkCrypt2_Dispose(crypt);
        CkHttpRequest_Dispose(req);
        CkHttp_Dispose(http);
        return;
    }

    // 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));
    printf("%s\n",CkXml_getXml(xmlResponse));
    CkHttpResponse_Dispose(resp);

    // Show how to get the Detail, which must be the ClientId,SessionId
    detail = CkXml_chilkatPath(xmlResponse,"soap:Body|AuthenticateResponse|AuthenticateResult|Detail|*");
    printf("Detail = %s\n",detail);


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

    }

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.