Sample code for 30+ languages & platforms
Java

WIN Air Freight - Send New Pouch Request

See more HTTP Misc Examples

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

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;
import com.chilkatsoft.chilkat2.Xml;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat HTTP API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();

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

        // Tell Chilkat to cache any received cookies to files in a particular directory
        http.setCookieDir("c:/qa_data/cookies");
        http.setSaveCookies(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.setSendCookies(true);

        // Build out XML pouch request...
        Xml xml = new Xml();
        xml.setTag("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.setEmitXmlDecl(false);

        String httpRequestBody = xml.getXml();
        HttpResponse resp = new HttpResponse();
        try {
            http.httpStr("POST", "http://integration.winwebconnect.com/api/v1/Awb", httpRequestBody, "utf-8", "application/xml", resp);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        Xml xmlResponse = new Xml();
        xmlResponse.loadXml(resp.getBodyStr());

        // See below for an example XML response body.
        System.out.println("Response Body:");
        System.out.println(xmlResponse.getXml());
        System.out.println("---");

        System.out.println("Response Header:");
        System.out.println(resp.getHeader());
        System.out.println("Success.");
    }
}