Swift
Swift
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 Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
// Set the "Accept" header to tell the web server that we'll accept an XML response.
http.accept = "application/xml"
// Tell Chilkat to cache any received cookies to files in a particular directory
http.cookieDir = "c:/qa_data/cookies"
http.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.sendCookies = true
// Build out XML pouch request...
let xml = CkoXml()!
xml.tag = "PouchDTO"
xml.updateChildContent(tagPath: "Mawb|AwbID", value: "")
xml.updateChildContent(tagPath: "Mawb|AwbNumber", value: "001-12312123")
xml.updateChildContent(tagPath: "Mawb|AwbStatus", value: "D")
xml.updateChildContent(tagPath: "Mawb|eAWB", value: "false")
xml.updateChildContent(tagPath: "Mawb|WithPaper", value: "false")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|WinID", value: "444444")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|AccountNumber", value: "12345")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Name", value: "AABC SHIPPING & PACKAGING, INC.")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Phone", value: "111-222-3334")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Fax", value: "222-111-3334")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Email", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Address|Line1", value: "500 HARBOR DRIVE")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Address|Line2", value: "SUITE B1211")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Address|Place", value: "BEAUFORT")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Address|PostalCode", value: "28516")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Address|StateProvince", value: "NC")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Address|Country|Code", value: "US")
xml.updateChildContent(tagPath: "Mawb|Parties|Shipper|Address|Country|Name", value: "U.S.A.")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|WinID", value: "0")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|AccountNumber", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Name", value: "DELTA MANUFACTURING")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Phone", value: "444-555-3333")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Fax", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Email", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Address|Line1", value: "185 RUE LAMANDE")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Address|Line2", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Address|Place", value: "PARIS")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Address|PostalCode", value: "75017")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Address|StateProvince", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Address|Country|Code", value: "FR")
xml.updateChildContent(tagPath: "Mawb|Parties|Consignee|Address|Country|Name", value: "FRANCE")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|WinID", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|AccountNumber", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Name", value: "AABC SHIPPING, INC.")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Phone", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Fax", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Email", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Address|Line1", value: "110 FARA WAY")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Address|Line2", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Address|Place", value: "OZ")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Address|PostalCode", value: "11222")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Address|StateProvince", value: "NY")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Address|Country|Code", value: "US")
xml.updateChildContent(tagPath: "Mawb|Parties|Notify|Address|Country|Name", value: "U.S.A.")
xml.updateChildContent(tagPath: "Mawb|Parties|Agent|WinID", value: "")
xml.updateChildContent(tagPath: "Mawb|Parties|Agent|AccountNumber", value: "FACCT#1234")
xml.updateChildContent(tagPath: "Mawb|Accounting|Identifier", value: "GEN")
xml.updateChildContent(tagPath: "Mawb|Accounting|Information", value: "SARFWER")
xml.updateChildContent(tagPath: "Mawb|Accounting|Identifier", value: "MCO")
xml.updateChildContent(tagPath: "Mawb|Accounting|Information", value: "WERWERWER")
xml.updateChildContent(tagPath: "Mawb|ShipmentReference|ReferenceNumber", value: "ZDFASF")
xml.updateChildContent(tagPath: "Mawb|ShipmentReference|AdditionalInformation", value: "ZDFASF")
xml.updateChildContent(tagPath: "Mawb|RoutingDetails|FromAirportCode", value: "EWN")
xml.updateChildContent(tagPath: "Mawb|RoutingDetails|ToAirportCode", value: "LON")
xml.updateChildContent(tagPath: "Mawb|RoutingDetails|CarrierCode", value: "AA")
xml.updateChildContent(tagPath: "Mawb|RoutingDetails|FlightNumber", value: "N123")
xml.updateChildContent(tagPath: "Mawb|RoutingDetails|FlightDate", value: "2016-11-30T00:00:00")
xml.updateChildContent(tagPath: "Mawb|ChargesDeclaration|CurrencyCode", value: "USD")
xml.updateChildContent(tagPath: "Mawb|ChargesDeclaration|ChargeCode", value: "PP")
xml.updateChildContent(tagPath: "Mawb|ChargesDeclaration|WeightOrValuation", value: "P")
xml.updateChildContent(tagPath: "Mawb|ChargesDeclaration|Other", value: "P")
xml.updateChildContent(tagPath: "Mawb|ChargesDeclaration|ValuesForCarriage", value: "1300.00")
xml.updateChildContent(tagPath: "Mawb|ChargesDeclaration|ValuesForCustoms", value: "12000.00")
xml.updateChildContent(tagPath: "Mawb|ChargesDeclaration|ValuesForInsurance", value: "11000.00")
xml.updateChildContent(tagPath: "Mawb|Handling|SpecialServiceInformation", value: "Please Notify Consigneetestwwwww")
xml.updateChildContent(tagPath: "Mawb|Handling|OtherServiceInformation", value: "")
xml.updateChildContent(tagPath: "Mawb|Handling|SCI", value: "")
xml.updateChildContent(tagPath: "Mawb|Handling|SpecialHandling|Code", value: "AOG")
xml.updateChildContent(tagPath: "Mawb|Handling|SpecialHandling|Code", value: "ATT")
xml.updateChildContent(tagPath: "Mawb|Rates|NumberOfPieces", value: "12")
xml.updateChildContent(tagPath: "Mawb|Rates|GrossWeight|Value", value: "244.70")
xml.updateChildContent(tagPath: "Mawb|Rates|GrossWeight|UOM", value: "L")
xml.updateChildContent(tagPath: "Mawb|Rates|SLAC", value: "12")
xml.updateChildContent(tagPath: "Mawb|Rates|RateClassCode", value: "N")
xml.updateChildContent(tagPath: "Mawb|Rates|CommodityItemNumber", value: "")
xml.updateChildContent(tagPath: "Mawb|Rates|ChargeableWeight", value: "245.0")
xml.updateChildContent(tagPath: "Mawb|Rates|RateOrCharge", value: "8.00")
xml.updateChildContent(tagPath: "Mawb|Rates|ChargeAmount", value: "1960.00")
xml.updateChildContent(tagPath: "Mawb|Rates|NatureAndQuantityOfGoods", value: "CONSOLIDATION PER ATTACHED MANIFEST.")
xml.updateChildContent(tagPath: "Mawb|Rates|Dims|Pcs", value: "12")
xml.updateChildContent(tagPath: "Mawb|Rates|Dims|Length", value: "4")
xml.updateChildContent(tagPath: "Mawb|Rates|Dims|Width", value: "8")
xml.updateChildContent(tagPath: "Mawb|Rates|Dims|Height", value: "4")
xml.updateChildContent(tagPath: "Mawb|Rates|Dims|UOM", value: "CMT")
xml.updateChildContent(tagPath: "Mawb|ChargesSummary|WeightCharge", value: "1960.00")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|Description", value: "AW")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|Amount", value: "123.00")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|ChargeIdentifier", value: "C")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|PrepaidCollect", value: "C")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|Description", value: "FC")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|Amount", value: "55.00")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|ChargeIdentifier", value: "A")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|PrepaidCollect", value: "P")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|Description", value: "FC")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|Amount", value: "101.00")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|ChargeIdentifier", value: "C")
xml.updateChildContent(tagPath: "Mawb|OtherCharges|PrepaidCollect", value: "C")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Name", value: "")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Email", value: "")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Name", value: "")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Email", value: "")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Name", value: "")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Email", value: "")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Name", value: "")
xml.updateChildContent(tagPath: "Mawb|EmailNotifications|Email", value: "")
xml.updateChildContent(tagPath: "Mawb|Execution|Date", value: "2015-08-07T00:00:00")
xml.updateChildContent(tagPath: "Mawb|Execution|Place", value: "OZ NY")
xml.updateChildContent(tagPath: "Mawb|Execution|ShipperSignature", value: "OAS FREIGHT FORWARDE")
xml.updateChildContent(tagPath: "Mawb|Execution|CarrierSignature", value: "OAS FREIGHT FORWARDE")
xml.updateChildContent(tagPath: "Hawbs|AwbNumber", value: "001-12312123")
xml.updateChildContent(tagPath: "Hawbs|HawbNumber", value: "CGL201107-27")
xml.updateChildContent(tagPath: "Hawbs|HawbStatus", value: "D")
xml.updateChildContent(tagPath: "Hawbs|NumberOfPieces", value: "12")
xml.updateChildContent(tagPath: "Hawbs|GrossWeight|Value", value: "244.70")
xml.updateChildContent(tagPath: "Hawbs|GrossWeight|UOM", value: "K")
xml.updateChildContent(tagPath: "Hawbs|Locations|PortOfOrigin|Code", value: "EWN")
xml.updateChildContent(tagPath: "Hawbs|Locations|PortOfDestination|Code", value: "LON")
xml.updateChildContent(tagPath: "Hawbs|Commodity", value: "HWB #: CGL20110")
xml.updateChildContent(tagPath: "Hawbs|SLAC", value: "12")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Name", value: "ABC SHIPPNG AGAIN")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Phone", value: "111-222-3333")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Fax", value: "")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Email", value: "")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Address|Line1", value: "100 MAIN STREET")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Address|Place", value: "OZ")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Address|PostalCode", value: "ZIP")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Address|StateProvince", value: "NY")
xml.updateChildContent(tagPath: "Hawbs|Parties|Shipper|Address|Country|Code", value: "US")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Name", value: "AABC SHIPPING & PACKAGING, INC.")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Phone", value: "111-222-3334")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Fax", value: "222-111-3334")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Email", value: "")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Address|Line1", value: "500 HARBOR DRIVE")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Address|Place", value: "BEAUFORT")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Address|PostalCode", value: "28516")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Address|StateProvince", value: "NC")
xml.updateChildContent(tagPath: "Hawbs|Parties|Consignee|Address|Country|Code", value: "US")
xml.emitXmlDecl = false
var httpRequestBody: String? = xml.getXml()
let resp = CkoHttpResponse()!
success = http.httpStr(verb: "POST", url: "http://integration.winwebconnect.com/api/v1/Awb", bodyStr: httpRequestBody, charset: "utf-8", contentType: "application/xml", response: resp)
if success == false {
print("\(http.lastErrorText!)")
return
}
let xmlResponse = CkoXml()!
xmlResponse.load(xmlData: resp.bodyStr)
// See below for an example XML response body.
print("Response Body:")
print("\(xmlResponse.getXml()!)")
print("---")
print("Response Header:")
print("\(resp.header!)")
print("Success.")
}