Rev 20640 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.aramex.impl;import java.util.Calendar;import com.aramex.stub.Address;import com.aramex.stub.ArrayOfShipment;import com.aramex.stub.ClientInfo;import com.aramex.stub.Contact;import com.aramex.stub.Dimensions;import com.aramex.stub.LabelInfo;import com.aramex.stub.Money;import com.aramex.stub.Party;import com.aramex.stub.ProcessedShipment;import com.aramex.stub.Service_1_0_PortType;import com.aramex.stub.Service_1_0_Service;import com.aramex.stub.Service_1_0_ServiceLocator;import com.aramex.stub.Shipment;import com.aramex.stub.ShipmentCreationRequest;import com.aramex.stub.ShipmentCreationResponse;import com.aramex.stub.ShipmentDetails;import com.aramex.stub.Weight;public class AramexTest {public static void main(String[] args) throws Exception {/**AccountCountryCode =JOAccountEntity = AMMAccountNumber= 20016AccountPin = 331421UserName = testingapi@aramex.comPassword = R123456789$rVersion = v1.0*/Service_1_0_Service aramexService = new Service_1_0_ServiceLocator();Service_1_0_PortType service = aramexService.getBasicHttpBinding_Service_1_0();ShipmentCreationRequest parameters = new ShipmentCreationRequest();Shipment [] shipArray = new Shipment[1];Shipment shpmnt = new Shipment();Party consignee = new Party();Contact contact = new Contact();contact.setCellPhone("9990381569");contact.setEmailAddress("amit.gupta@shop2020.in");contact.setPersonName("Amit Gupta");contact.setPhoneNumber1("1234567890");contact.setCompanyName("test");consignee.setContact(contact);Address consigneeAddress = new Address();consigneeAddress.setLine1("356, Divine Grace, Sector Omega-IV");consigneeAddress.setLine2("Greater Noida, Gautam Budh Nagar");consigneeAddress.setCity("Noida");consigneeAddress.setStateOrProvinceCode("UP");consigneeAddress.setPostCode("201301");consigneeAddress.setCountryCode("IN");consignee.setPartyAddress(consigneeAddress);shpmnt.setConsignee(consignee );shpmnt.setShipper(getTestShipper());shpmnt.setPickupLocation("Gurgaon");shpmnt.setShippingDateTime(Calendar.getInstance());Calendar dueDate = Calendar.getInstance();dueDate.add(Calendar.DATE, 5);shpmnt.setDueDate(dueDate);ShipmentDetails details = new ShipmentDetails();details.setProductGroup("DOM");details.setProductType("CDA");details.setPaymentType("P");Weight actualWeight = new Weight();actualWeight.setUnit("KG");actualWeight.setValue(0.3);details.setActualWeight(actualWeight);details.setChargeableWeight(new Weight("KG", 0.3));details.setDimensions(new Dimensions(10, 10, 10, "CM"));details.setDescriptionOfGoods("Electronics");details.setGoodsOriginCountry("IN");details.setServices("CODS");//if cod thendetails.setCashOnDeliveryAmount(new Money("INR", 600));details.setCustomsValueAmount(new Money("INR", 550));details.setNumberOfPieces(1);shpmnt.setDetails(details);//shpmnt.srshipArray[0]=shpmnt;LabelInfo labelInfo = new LabelInfo();labelInfo.setReportID(9729);labelInfo.setReportType("URL");parameters.setLabelInfo(labelInfo);parameters.setClientInfo(getTestClientInfo());parameters.setShipments(shipArray);ShipmentCreationResponse scr = service.createShipments(parameters);if(scr.getHasErrors() && (scr.getNotifications() == null ||scr.getShipments()[0]==null)) {System.out.println("Some error " + scr.getNotifications()[0]);return;}ProcessedShipment ps = scr.getShipments()[0];System.out.println(ps.getID());}private static Party getTestShipper() {Party shipper = new Party();shipper.setAccountNumber("DELTST002");Contact sc = new Contact();sc.setEmailAddress("testingapi@aramex.com");sc.setCellPhone("9990381569");sc.setCompanyName("TEST");sc.setPersonName("Test");sc.setPhoneNumber1("1234567890");shipper.setContact(sc);Address shipperAddress = new Address();shipperAddress.setLine1("Test");shipperAddress.setCity("Ggn");shipperAddress.setCountryCode("IN");shipperAddress.setPostCode("110001");shipper.setPartyAddress(shipperAddress);return shipper;}private static ClientInfo getTestClientInfo() {ClientInfo clientInfo = new ClientInfo();clientInfo.setAccountCountryCode("IN");clientInfo.setAccountNumber("DELTST002");clientInfo.setVersion("v1.0");clientInfo.setAccountEntity("DEL");clientInfo.setUserName("testingapi@aramex.com");clientInfo.setPassword("R123456789$r");clientInfo.setAccountPin("231164");return clientInfo;}}