Chilkat Examples

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

MFC Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(MFC) WIN Air Freight - Send New Pouch Request

Sends a "POST /api/v1/Awb" to send a new pouch request.

Chilkat C/C++ Library Downloads

MS Visual C/C++ Libs

See Also: Using MFC CString in Chilkat

#include <CkHttp.h>
#include <CkXml.h>
#include <CkHttpResponse.h>

void ChilkatSample(void)
    {
    CkString strOut;

    // This example assumes the Chilkat HTTP API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http;

    // Set the "Accept" header to tell the web server that we'll accept an XML response.
    http.put_Accept("application/xml");

    // Tell Chilkat to cache any received cookies to files in a particular directory
    http.put_CookieDir("c:/qa_data/cookies");
    http.put_SaveCookies(true);

    // Also tell Chilkat to load and send matching cookies from the CookieDir.
    // The authToken cookie is first obtained in the login request. Each subsequent
    // request sends the authToken cookie and saves the new authToken cookie to the CookieDir.
    http.put_SendCookies(true);

    // Build out XML pouch request...
    CkXml xml;
    xml.put_Tag("PouchDTO");
    xml.UpdateChildContent("Mawb|AwbID","");
    xml.UpdateChildContent("Mawb|AwbNumber","001-12312123");
    xml.UpdateChildContent("Mawb|AwbStatus","D");
    xml.UpdateChildContent("Mawb|eAWB","false");
    xml.UpdateChildContent("Mawb|WithPaper","false");
    xml.UpdateChildContent("Mawb|Parties|Shipper|WinID","444444");
    xml.UpdateChildContent("Mawb|Parties|Shipper|AccountNumber","12345");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Name","AABC SHIPPING & PACKAGING, INC.");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Phone","111-222-3334");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Fax","222-111-3334");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Email","");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Address|Line1","500 HARBOR DRIVE");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Address|Line2","SUITE B1211");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Address|Place","BEAUFORT");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Address|PostalCode","28516");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Address|StateProvince","NC");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Address|Country|Code","US");
    xml.UpdateChildContent("Mawb|Parties|Shipper|Address|Country|Name","U.S.A.");
    xml.UpdateChildContent("Mawb|Parties|Consignee|WinID","0");
    xml.UpdateChildContent("Mawb|Parties|Consignee|AccountNumber","");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Name","DELTA MANUFACTURING");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Phone","444-555-3333");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Fax","");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Email","");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Address|Line1","185 RUE LAMANDE");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Address|Line2","");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Address|Place","PARIS");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Address|PostalCode","75017");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Address|StateProvince","");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Address|Country|Code","FR");
    xml.UpdateChildContent("Mawb|Parties|Consignee|Address|Country|Name","FRANCE");
    xml.UpdateChildContent("Mawb|Parties|Notify|WinID","");
    xml.UpdateChildContent("Mawb|Parties|Notify|AccountNumber","");
    xml.UpdateChildContent("Mawb|Parties|Notify|Name","AABC SHIPPING, INC.");
    xml.UpdateChildContent("Mawb|Parties|Notify|Phone","");
    xml.UpdateChildContent("Mawb|Parties|Notify|Fax","");
    xml.UpdateChildContent("Mawb|Parties|Notify|Email","");
    xml.UpdateChildContent("Mawb|Parties|Notify|Address|Line1","110 FARA WAY");
    xml.UpdateChildContent("Mawb|Parties|Notify|Address|Line2","");
    xml.UpdateChildContent("Mawb|Parties|Notify|Address|Place","OZ");
    xml.UpdateChildContent("Mawb|Parties|Notify|Address|PostalCode","11222");
    xml.UpdateChildContent("Mawb|Parties|Notify|Address|StateProvince","NY");
    xml.UpdateChildContent("Mawb|Parties|Notify|Address|Country|Code","US");
    xml.UpdateChildContent("Mawb|Parties|Notify|Address|Country|Name","U.S.A.");
    xml.UpdateChildContent("Mawb|Parties|Agent|WinID","");
    xml.UpdateChildContent("Mawb|Parties|Agent|AccountNumber","FACCT#1234");
    xml.UpdateChildContent("Mawb|Accounting|Identifier","GEN");
    xml.UpdateChildContent("Mawb|Accounting|Information","SARFWER");
    xml.UpdateChildContent("Mawb|Accounting|Identifier","MCO");
    xml.UpdateChildContent("Mawb|Accounting|Information","WERWERWER");
    xml.UpdateChildContent("Mawb|ShipmentReference|ReferenceNumber","ZDFASF");
    xml.UpdateChildContent("Mawb|ShipmentReference|AdditionalInformation","ZDFASF");
    xml.UpdateChildContent("Mawb|RoutingDetails|FromAirportCode","EWN");
    xml.UpdateChildContent("Mawb|RoutingDetails|ToAirportCode","LON");
    xml.UpdateChildContent("Mawb|RoutingDetails|CarrierCode","AA");
    xml.UpdateChildContent("Mawb|RoutingDetails|FlightNumber","N123");
    xml.UpdateChildContent("Mawb|RoutingDetails|FlightDate","2016-11-30T00:00:00");
    xml.UpdateChildContent("Mawb|ChargesDeclaration|CurrencyCode","USD");
    xml.UpdateChildContent("Mawb|ChargesDeclaration|ChargeCode","PP");
    xml.UpdateChildContent("Mawb|ChargesDeclaration|WeightOrValuation","P");
    xml.UpdateChildContent("Mawb|ChargesDeclaration|Other","P");
    xml.UpdateChildContent("Mawb|ChargesDeclaration|ValuesForCarriage","1300.00");
    xml.UpdateChildContent("Mawb|ChargesDeclaration|ValuesForCustoms","12000.00");
    xml.UpdateChildContent("Mawb|ChargesDeclaration|ValuesForInsurance","11000.00");
    xml.UpdateChildContent("Mawb|Handling|SpecialServiceInformation","Please Notify Consigneetestwwwww");
    xml.UpdateChildContent("Mawb|Handling|OtherServiceInformation","");
    xml.UpdateChildContent("Mawb|Handling|SCI","");
    xml.UpdateChildContent("Mawb|Handling|SpecialHandling|Code","AOG");
    xml.UpdateChildContent("Mawb|Handling|SpecialHandling|Code","ATT");
    xml.UpdateChildContent("Mawb|Rates|NumberOfPieces","12");
    xml.UpdateChildContent("Mawb|Rates|GrossWeight|Value","244.70");
    xml.UpdateChildContent("Mawb|Rates|GrossWeight|UOM","L");
    xml.UpdateChildContent("Mawb|Rates|SLAC","12");
    xml.UpdateChildContent("Mawb|Rates|RateClassCode","N");
    xml.UpdateChildContent("Mawb|Rates|CommodityItemNumber","");
    xml.UpdateChildContent("Mawb|Rates|ChargeableWeight","245.0");
    xml.UpdateChildContent("Mawb|Rates|RateOrCharge","8.00");
    xml.UpdateChildContent("Mawb|Rates|ChargeAmount","1960.00");
    xml.UpdateChildContent("Mawb|Rates|NatureAndQuantityOfGoods","CONSOLIDATION PER ATTACHED MANIFEST.");
    xml.UpdateChildContent("Mawb|Rates|Dims|Pcs","12");
    xml.UpdateChildContent("Mawb|Rates|Dims|Length","4");
    xml.UpdateChildContent("Mawb|Rates|Dims|Width","8");
    xml.UpdateChildContent("Mawb|Rates|Dims|Height","4");
    xml.UpdateChildContent("Mawb|Rates|Dims|UOM","CMT");
    xml.UpdateChildContent("Mawb|ChargesSummary|WeightCharge","1960.00");
    xml.UpdateChildContent("Mawb|OtherCharges|Description","AW");
    xml.UpdateChildContent("Mawb|OtherCharges|Amount","123.00");
    xml.UpdateChildContent("Mawb|OtherCharges|ChargeIdentifier","C");
    xml.UpdateChildContent("Mawb|OtherCharges|PrepaidCollect","C");
    xml.UpdateChildContent("Mawb|OtherCharges|Description","FC");
    xml.UpdateChildContent("Mawb|OtherCharges|Amount","55.00");
    xml.UpdateChildContent("Mawb|OtherCharges|ChargeIdentifier","A");
    xml.UpdateChildContent("Mawb|OtherCharges|PrepaidCollect","P");
    xml.UpdateChildContent("Mawb|OtherCharges|Description","FC");
    xml.UpdateChildContent("Mawb|OtherCharges|Amount","101.00");
    xml.UpdateChildContent("Mawb|OtherCharges|ChargeIdentifier","C");
    xml.UpdateChildContent("Mawb|OtherCharges|PrepaidCollect","C");
    xml.UpdateChildContent("Mawb|EmailNotifications|Name","");
    xml.UpdateChildContent("Mawb|EmailNotifications|Email","");
    xml.UpdateChildContent("Mawb|EmailNotifications|Name","");
    xml.UpdateChildContent("Mawb|EmailNotifications|Email","");
    xml.UpdateChildContent("Mawb|EmailNotifications|Name","");
    xml.UpdateChildContent("Mawb|EmailNotifications|Email","");
    xml.UpdateChildContent("Mawb|EmailNotifications|Name","");
    xml.UpdateChildContent("Mawb|EmailNotifications|Email","");
    xml.UpdateChildContent("Mawb|Execution|Date","2015-08-07T00:00:00");
    xml.UpdateChildContent("Mawb|Execution|Place","OZ NY");
    xml.UpdateChildContent("Mawb|Execution|ShipperSignature","OAS FREIGHT FORWARDE");
    xml.UpdateChildContent("Mawb|Execution|CarrierSignature","OAS FREIGHT FORWARDE");
    xml.UpdateChildContent("Hawbs|AwbNumber","001-12312123");
    xml.UpdateChildContent("Hawbs|HawbNumber","CGL201107-27");
    xml.UpdateChildContent("Hawbs|HawbStatus","D");
    xml.UpdateChildContent("Hawbs|NumberOfPieces","12");
    xml.UpdateChildContent("Hawbs|GrossWeight|Value","244.70");
    xml.UpdateChildContent("Hawbs|GrossWeight|UOM","K");
    xml.UpdateChildContent("Hawbs|Locations|PortOfOrigin|Code","EWN");
    xml.UpdateChildContent("Hawbs|Locations|PortOfDestination|Code","LON");
    xml.UpdateChildContent("Hawbs|Commodity","HWB #: CGL20110");
    xml.UpdateChildContent("Hawbs|SLAC","12");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Name","ABC SHIPPNG AGAIN");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Phone","111-222-3333");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Fax","");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Email","");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Address|Line1","100 MAIN STREET");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Address|Place","OZ");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Address|PostalCode","ZIP");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Address|StateProvince","NY");
    xml.UpdateChildContent("Hawbs|Parties|Shipper|Address|Country|Code","US");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Name","AABC SHIPPING & PACKAGING, INC.");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Phone","111-222-3334");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Fax","222-111-3334");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Email","");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Address|Line1","500 HARBOR DRIVE");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Address|Place","BEAUFORT");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Address|PostalCode","28516");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Address|StateProvince","NC");
    xml.UpdateChildContent("Hawbs|Parties|Consignee|Address|Country|Code","US");
    xml.put_EmitXmlDecl(false);

    CkHttpResponse *resp = http.PText("POST","http://integration.winwebconnect.com/api/v1/Awb",xml.getXml(),"utf-8","application/xml",false,false);
    if (http.get_LastMethodSuccess() != true) {
        strOut.append(http.lastErrorText());
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    CkXml xmlResponse;
    xmlResponse.LoadXml(resp->bodyStr());

    // See below for an example XML response body.
    strOut.append("Response Body:");
    strOut.append("\r\n");
    strOut.append(xmlResponse.getXml());
    strOut.append("\r\n");
    strOut.append("---");
    strOut.append("\r\n");

    strOut.append("Response Header:");
    strOut.append("\r\n");
    strOut.append(resp->header());
    strOut.append("\r\n");

    delete resp;
    strOut.append("Success.");
    strOut.append("\r\n");


    SetDlgItemText(IDC_EDIT1,strOut.getUnicode());

    }

 

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