Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

Peoplevox WMS Authentication

See more HTTP Examples

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

Chilkat Rust Downloads

Rust

// 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>
// 

let sb_soap_xml = chilkat::StringBuilder::new();
let _ = sb_soap_xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
let _ = sb_soap_xml.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:peop=\"http://www.peoplevox.net/\">");
let _ = sb_soap_xml.append("   <soapenv:Header/>");
let _ = sb_soap_xml.append("   <soapenv:Body>");
let _ = sb_soap_xml.append("      <peop:Authenticate>");
let _ = sb_soap_xml.append("         <peop:clientId>PEOPLEVOX_CLIENT_ID</peop:clientId>");
let _ = sb_soap_xml.append("         <peop:username>PEOPLEVOX_USERNAME</peop:username>");
let _ = sb_soap_xml.append("         <peop:password>PEOPLEVOX_BASE64_PASSWORD</peop:password>");
let _ = sb_soap_xml.append("      </peop:Authenticate>");
let _ = sb_soap_xml.append("   </soapenv:Body>");
let _ = sb_soap_xml.append("</soapenv:Envelope>");

// Base64 encode the password and update the SOAP XML.
let crypt = chilkat::Crypt2::new();
let password_base64 = crypt.encode_string("PEOPLEVOX_PASSWORD", "utf-8", "base64").unwrap_or_default();
let num_replacements = sb_soap_xml.replace("PEOPLEVOX_BASE64_PASSWORD", &password_base64);

let req = chilkat::HttpRequest::new();
req.set_http_verb("POST");
req.set_send_charset(true);
req.set_charset("utf-8");
req.add_header("Content-Type", "text/xml");
req.add_header("SOAPAction", "http://www.peoplevox.net/Authenticate");
req.set_path("/PEOPLEVOX_CLIENT_ID/resources/integrationservicev4.asmx");
let _ = req.load_body_from_string(&sb_soap_xml.get_as_string().unwrap_or_default(), "utf-8").is_ok();

let http = chilkat::Http::new();
http.set_follow_redirects(true);

let resp = chilkat::HttpResponse::new();
if http.http_s_req("qac.peoplevox.net", 443, true, &req, &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

// We should expect a 200 response if successful.
if resp.status_code() != 200 {
    println!("Response StatusCode = {}", resp.status_code());
    println!("Response StatusLine: {}", resp.status_line());
    println!("Response Header:");
    println!("{}", resp.header());
    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>
// 

let xml_response = chilkat::Xml::new();
let _ = xml_response.load_xml(&resp.body_str()).is_ok();
println!("{}", xml_response.get_xml().unwrap_or_default());

// Show how to get the Detail, which must be the ClientId,SessionId
let detail = xml_response.chilkat_path("soap:Body|AuthenticateResponse|AuthenticateResult|Detail|*").unwrap_or_default();
println!("Detail = {}", detail);