Rust Requires Chilkat v11.0.0+
Rust
Aruba Fatturazione Elettronica Get Zip by Filename
See more Aruba Fatturazione Examples
Returns an invoice with all of its notifications in Zip format (e.g. IT01879020517_abcde.xml.p7m).Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
// Implements the following CURL command:
// curl -X GET https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/getZipByFilename?filename=IT01879020517_jtlk1.xml.p7m \
// -H "Accept: application/json" \
// -H "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Adds the "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" header.
http.set_auth_token("NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=");
http.set_request_header("Accept", "application/json");
let bd_zip = chilkat::BinData::new();
if http.quick_get_bd("https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/getZipByFilename?filename=IT01879020517_jtlk1.xml.p7m", &bd_zip).is_err() {
println!("{}", http.last_error_text());
return;
}
let resp_status_code = http.last_status();
println!("response status code = {}", resp_status_code);
if resp_status_code != 200 {
// If it failed, the response body will not contain the .zip file data.
// It will likely contain an error message.
println!("{}", bd_zip.get_string("utf-8").unwrap_or_default());
println!("Failed.");
return;
}
// Open the zip and extract the .p7m
let zip = chilkat::Zip::new();
if zip.open_bd(&bd_zip).is_err() {
println!("{}", zip.last_error_text());
return;
}
// If desired, we can unzip to the filesystem..
let num_unzipped = zip.unzip("c:/mySignedInvoices");
if num_unzipped < 0 {
println!("{}", zip.last_error_text());
return;
}
// Alternatively, we can unzip into memory..
let entry = chilkat::ZipEntry::new();
if zip.entry_at(0, &entry).is_err() {
println!("{}", zip.last_error_text());
return;
}
let bd_p7m = chilkat::BinData::new();
if entry.unzip_to_bd(&bd_p7m).is_err() {
println!("{}", entry.last_error_text());
return;
}
// Verify the signature and extract the XML from the p7m
// If the signature verification is successful, the contents of bdP7m are unwrapped and what
// remains is the original signed document..
let crypt = chilkat::Crypt2::new();
if crypt.opaque_verify_bd(&bd_p7m).is_err() {
println!("{}", crypt.last_error_text());
return;
}
println!("The signature was verified.");
// The bdp7m now contains the XML that was originally signed.
println!("Original XML:");
println!("{}", bd_p7m.get_string("utf-8").unwrap_or_default());