| Line 1... |
Line 1... |
| 1 |
package com.bluedart.impl;
|
1 |
package com.bluedart.impl;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.net.MalformedURLException;
|
| - |
|
4 |
import java.net.URL;
|
| - |
|
5 |
import java.rmi.RemoteException;
|
| 3 |
import in.shop2020.model.v1.order.Order;
|
6 |
import java.util.GregorianCalendar;
|
| 4 |
|
- |
|
| 5 |
import java.util.List;
|
7 |
import java.util.List;
|
| 6 |
|
8 |
|
| - |
|
9 |
import javax.xml.bind.JAXBElement;
|
| - |
|
10 |
import javax.xml.datatype.DatatypeConfigurationException;
|
| - |
|
11 |
import javax.xml.datatype.DatatypeFactory;
|
| - |
|
12 |
import javax.xml.datatype.XMLGregorianCalendar;
|
| - |
|
13 |
import javax.xml.namespace.QName;
|
| - |
|
14 |
import javax.xml.rpc.ServiceException;
|
| - |
|
15 |
|
| - |
|
16 |
import com.bluedart.entities.ArrayOfDimension;
|
| - |
|
17 |
import com.bluedart.entities.CommodityDetail;
|
| - |
|
18 |
import com.bluedart.entities.Consignee;
|
| - |
|
19 |
import com.bluedart.entities.Dimension;
|
| - |
|
20 |
import com.bluedart.entities.ObjectFactory;
|
| - |
|
21 |
import com.bluedart.entities.Services;
|
| - |
|
22 |
import com.bluedart.entities.Shipper;
|
| - |
|
23 |
import com.bluedart.entities.UserProfile;
|
| - |
|
24 |
import com.bluedart.entities.WayBillGenerationRequest;
|
| - |
|
25 |
import com.bluedart.entities.WayBillGenerationResponse;
|
| - |
|
26 |
import com.bluedart.enums.ProductType;
|
| - |
|
27 |
import com.bluedart.tempuri.IWayBillGeneration;
|
| - |
|
28 |
import com.bluedart.tempuri.WayBillGeneration;
|
| 7 |
import com.providers.logistics.Provider;
|
29 |
import com.providers.logistics.Provider;
|
| 8 |
|
30 |
|
| - |
|
31 |
import in.shop2020.model.v1.order.Order;
|
| - |
|
32 |
|
| 9 |
public class Bluedart implements Provider{
|
33 |
public class Bluedart implements Provider{
|
| - |
|
34 |
|
| - |
|
35 |
private final String LOGIN_ID = "FA316326";
|
| - |
|
36 |
private final String LICENCE_KEY = "5f1740fdfb8196e7980faea7fe52dd0d";
|
| - |
|
37 |
private UserProfile userProfile;
|
| - |
|
38 |
private static Bluedart bluedart;
|
| - |
|
39 |
|
| - |
|
40 |
static{
|
| - |
|
41 |
synchronized(Bluedart.class){
|
| - |
|
42 |
bluedart = new Bluedart();
|
| - |
|
43 |
bluedart.createProfile();
|
| - |
|
44 |
}
|
| - |
|
45 |
}
|
| - |
|
46 |
|
| - |
|
47 |
private void createProfile(){
|
| - |
|
48 |
userProfile = new UserProfile();
|
| - |
|
49 |
}
|
| - |
|
50 |
|
| - |
|
51 |
private static Bluedart getBluedartService(){
|
| - |
|
52 |
return bluedart;
|
| - |
|
53 |
}
|
| - |
|
54 |
|
| 10 |
|
55 |
|
| 11 |
public String getAirwayBillNo(List<Order> orders) {
|
56 |
public String getAirwayBillNo(List<Order> orders) throws MalformedURLException {
|
| - |
|
57 |
System.setProperty(
|
| - |
|
58 |
"com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump",
|
| - |
|
59 |
"true");
|
| - |
|
60 |
|
| - |
|
61 |
|
| - |
|
62 |
UserProfile userProfile = new UserProfile();
|
| - |
|
63 |
WayBillGenerationRequest wayBillGenerationRequest = new WayBillGenerationRequest();
|
| - |
|
64 |
|
| - |
|
65 |
ObjectFactory objectFactory= new ObjectFactory();
|
| - |
|
66 |
|
| - |
|
67 |
Consignee consignee = new Consignee();
|
| - |
|
68 |
JAXBElement<String> address1Value = objectFactory
|
| - |
|
69 |
.createConsigneeConsigneeAddress1("Flat201,MIG76");
|
| - |
|
70 |
JAXBElement<String> address2Value = objectFactory
|
| - |
|
71 |
.createConsigneeConsigneeAddress2("DRC phase-2,HyderNagar");
|
| - |
|
72 |
JAXBElement<String> address3Value = objectFactory
|
| - |
|
73 |
.createConsigneeConsigneeAddress3("HyderNagar,Hyderabad-500072");
|
| - |
|
74 |
JAXBElement<String> attentionValue = objectFactory
|
| - |
|
75 |
.createConsigneeConsigneeAttention("Mr.");
|
| - |
|
76 |
JAXBElement<String> mobileValue = objectFactory
|
| - |
|
77 |
.createConsigneeConsigneeMobile("09666712227");
|
| - |
|
78 |
JAXBElement<String> nameValue = objectFactory
|
| - |
|
79 |
.createConsigneeConsigneeName("Nagesh Chintala");
|
| - |
|
80 |
JAXBElement<String> pincodeValue = objectFactory
|
| - |
|
81 |
.createConsigneeConsigneePincode("400025");
|
| - |
|
82 |
|
| - |
|
83 |
consignee.setConsigneeAddress1(address1Value);
|
| - |
|
84 |
consignee.setConsigneeAddress2(address2Value);
|
| - |
|
85 |
consignee.setConsigneeAddress3(address3Value);
|
| - |
|
86 |
consignee.setConsigneeAttention(attentionValue);
|
| - |
|
87 |
consignee.setConsigneeMobile(mobileValue);
|
| - |
|
88 |
consignee.setConsigneeName(nameValue);
|
| - |
|
89 |
consignee.setConsigneePincode(pincodeValue);
|
| - |
|
90 |
consignee.setConsigneeTelephone(objectFactory
|
| - |
|
91 |
.createConsigneeConsigneeTelephone("1111111111"));
|
| - |
|
92 |
consignee.setConsigneeMobile(objectFactory
|
| - |
|
93 |
.createConsigneeConsigneeMobile("1111111111"));
|
| - |
|
94 |
JAXBElement<Consignee> consigneeValue = objectFactory
|
| - |
|
95 |
.createConsignee(consignee);
|
| - |
|
96 |
|
| - |
|
97 |
wayBillGenerationRequest.setConsignee(consigneeValue);
|
| - |
|
98 |
|
| - |
|
99 |
Services services = new Services();
|
| - |
|
100 |
|
| - |
|
101 |
services.setActualWeight(1.0);
|
| - |
|
102 |
services.setCollectableAmount(0.0);
|
| - |
|
103 |
|
| - |
|
104 |
CommodityDetail commodityDetail = new CommodityDetail();
|
| - |
|
105 |
|
| - |
|
106 |
commodityDetail.setCommodityDetail1(objectFactory
|
| - |
|
107 |
.createCommodityDetailCommodityDetail1("Commodity 1"));
|
| - |
|
108 |
commodityDetail.setCommodityDetail2(objectFactory
|
| - |
|
109 |
.createCommodityDetailCommodityDetail2("Commodity 2"));
|
| - |
|
110 |
commodityDetail.setCommodityDetail3(objectFactory
|
| - |
|
111 |
.createCommodityDetailCommodityDetail3("Commodity 3"));
|
| - |
|
112 |
//services.setCommodity(objectFactory
|
| - |
|
113 |
//.createCommodityDetail(commodityDetail));
|
| - |
|
114 |
|
| - |
|
115 |
services.setCommodity(objectFactory
|
| - |
|
116 |
.createServicesCommodity(commodityDetail));
|
| - |
|
117 |
|
| - |
|
118 |
services.setCreditReferenceNo(objectFactory
|
| - |
|
119 |
.createServicesCreditReferenceNo("12345abdnn"));
|
| - |
|
120 |
services.setDeclaredValue(1.0);
|
| - |
|
121 |
|
| - |
|
122 |
ArrayOfDimension arrayOfDimension = new ArrayOfDimension();
|
| - |
|
123 |
Dimension d = new Dimension();
|
| - |
|
124 |
d.setBreadth(1.0);
|
| - |
|
125 |
d.setCount(1);
|
| - |
|
126 |
d.setHeight(1.0);
|
| - |
|
127 |
d.setLength(1.0);
|
| - |
|
128 |
arrayOfDimension.getDimension().add(d);
|
| - |
|
129 |
|
| - |
|
130 |
services.setDimensions(objectFactory
|
| - |
|
131 |
.createServicesDimensions(arrayOfDimension));
|
| - |
|
132 |
|
| - |
|
133 |
services.setInvoiceNo(objectFactory.createServicesInvoiceNo("12345"));
|
| - |
|
134 |
services.setPackType(objectFactory.createServicesPackType(""));
|
| - |
|
135 |
|
| - |
|
136 |
GregorianCalendar c = new GregorianCalendar();
|
| - |
|
137 |
c.set(2014,11 ,4);
|
| - |
|
138 |
// c.setTime(yourDate);
|
| - |
|
139 |
XMLGregorianCalendar date2;
|
| - |
|
140 |
try {
|
| - |
|
141 |
date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
|
| - |
|
142 |
services.setPickupDate(date2);
|
| - |
|
143 |
} catch (DatatypeConfigurationException e) {
|
| 12 |
// TODO Auto-generated method stub
|
144 |
// TODO Auto-generated catch block
|
| - |
|
145 |
e.printStackTrace();
|
| - |
|
146 |
}
|
| - |
|
147 |
|
| - |
|
148 |
services.setPickupTime(objectFactory.createServicesPickupTime("1800"));
|
| - |
|
149 |
services.setPieceCount(1);
|
| - |
|
150 |
services.setProductCode(objectFactory.createServicesProductCode("A"));
|
| - |
|
151 |
services.setProductType(ProductType.DUTIABLES);
|
| - |
|
152 |
services.setSpecialInstruction(objectFactory
|
| - |
|
153 |
.createServicesSpecialInstruction("1"));
|
| - |
|
154 |
services.setSubProductCode(objectFactory
|
| - |
|
155 |
.createServicesSubProductCode(""));
|
| - |
|
156 |
|
| - |
|
157 |
wayBillGenerationRequest.setServices(objectFactory
|
| - |
|
158 |
.createServices(services));
|
| - |
|
159 |
|
| - |
|
160 |
Shipper shipper = new Shipper();
|
| - |
|
161 |
shipper.setCustomerAddress1(objectFactory
|
| - |
|
162 |
.createShipperCustomerAddress1("1"));
|
| - |
|
163 |
shipper.setCustomerAddress2(objectFactory
|
| - |
|
164 |
.createShipperCustomerAddress2("1"));
|
| - |
|
165 |
shipper.setCustomerAddress3(objectFactory
|
| - |
|
166 |
.createShipperCustomerAddress3("1"));
|
| - |
|
167 |
shipper.setCustomerCode(objectFactory
|
| - |
|
168 |
.createShipperCustomerCode("525755"));
|
| - |
|
169 |
shipper.setCustomerMobile(objectFactory
|
| - |
|
170 |
.createShipperCustomerMobile("1111111111"));
|
| - |
|
171 |
shipper.setCustomerEmailID(objectFactory
|
| - |
|
172 |
.createShipperCustomerEmailID("a@b.com"));
|
| - |
|
173 |
shipper.setCustomerName(objectFactory.createShipperCustomerName("xyz"));
|
| - |
|
174 |
shipper.setCustomerPincode(objectFactory
|
| - |
|
175 |
.createShipperCustomerPincode("110074"));
|
| - |
|
176 |
shipper.setCustomerTelephone(objectFactory
|
| - |
|
177 |
.createShipperCustomerTelephone("1111111111"));
|
| - |
|
178 |
shipper.setIsToPayCustomer(false);
|
| - |
|
179 |
shipper.setOriginArea(objectFactory.createShipperOriginArea("DEL"));
|
| - |
|
180 |
shipper.setSender(objectFactory.createShipperSender("xyz"));
|
| - |
|
181 |
shipper.setVendorCode(objectFactory.createShipperVendorCode(""));
|
| - |
|
182 |
|
| - |
|
183 |
wayBillGenerationRequest.setShipper(objectFactory
|
| - |
|
184 |
.createShipper(shipper));
|
| - |
|
185 |
|
| - |
|
186 |
//JAXBElement<String> apiValue = objectFactory
|
| - |
|
187 |
// .createUserProfileApiType("S");
|
| - |
|
188 |
JAXBElement<String> custcodeValue = objectFactory
|
| - |
|
189 |
.createUserProfileCustomercode("316326");
|
| - |
|
190 |
JAXBElement<String> licencekeyValue = objectFactory
|
| - |
|
191 |
.createUserProfileLicenceKey("5f1740fdfb8196e7980faea7fe52dd0d");
|
| - |
|
192 |
JAXBElement<String> loginidValue = objectFactory
|
| - |
|
193 |
.createUserProfileLoginID("FA316326");
|
| - |
|
194 |
JAXBElement<String> versionValue = objectFactory
|
| - |
|
195 |
.createUserProfileVersion("1.3");
|
| - |
|
196 |
|
| - |
|
197 |
//userProfile.setApiType(apiValue);
|
| - |
|
198 |
userProfile.setArea(objectFactory.createUserProfileArea("FAR"));
|
| - |
|
199 |
userProfile.setCustomercode(custcodeValue);
|
| - |
|
200 |
userProfile.setPassword(objectFactory.createUserProfilePassword(""));
|
| - |
|
201 |
userProfile.setIsAdmin(objectFactory.createUserProfileIsAdmin("Y"));
|
| - |
|
202 |
userProfile.setLicenceKey(licencekeyValue);
|
| - |
|
203 |
userProfile.setLoginID(loginidValue);
|
| - |
|
204 |
userProfile.setVersion(versionValue);
|
| - |
|
205 |
|
| - |
|
206 |
com.bluedart.tempuri.ObjectFactory objectFactory1 = new com.bluedart.tempuri.ObjectFactory();
|
| - |
|
207 |
JAXBElement<UserProfile> userProfileValue = objectFactory1
|
| - |
|
208 |
.createGenerateWayBillProfile(userProfile);
|
| - |
|
209 |
|
| - |
|
210 |
JAXBElement<WayBillGenerationRequest> wayBillGenerationRequestValue = objectFactory
|
| - |
|
211 |
.createWayBillGenerationRequest(wayBillGenerationRequest);
|
| - |
|
212 |
|
| - |
|
213 |
|
| - |
|
214 |
URL u = new URL("http://netconnect.bluedart.com/Demo/ShippingAPI/WayBill/WayBillGeneration.svc?wsdl");
|
| - |
|
215 |
|
| - |
|
216 |
WayBillGeneration iway1 = new WayBillGeneration(u, new QName("http://tempuri.org/","WayBillGeneration"));
|
| - |
|
217 |
|
| - |
|
218 |
IWayBillGeneration iway = iway1.getWSHttpBindingIWayBillGeneration();
|
| - |
|
219 |
|
| - |
|
220 |
|
| - |
|
221 |
WayBillGenerationResponse response = iway.generateWayBill(
|
| - |
|
222 |
wayBillGenerationRequest, userProfile);
|
| - |
|
223 |
|
| - |
|
224 |
System.out.println("response--" + response);
|
| - |
|
225 |
System.out.println("awb "+response.getAWBNo().getValue());
|
| - |
|
226 |
System.out.println(response.getStatus().getValue().getWayBillGenerationStatus());
|
| 13 |
return null;
|
227 |
return "";
|
| - |
|
228 |
|
| - |
|
229 |
}
|
| - |
|
230 |
|
| - |
|
231 |
|
| - |
|
232 |
public static void main(String[] args) throws MalformedURLException {
|
| - |
|
233 |
Bluedart bl_ser = getBluedartService();
|
| - |
|
234 |
bl_ser.getAirwayBillNo(null);
|
| 14 |
}
|
235 |
}
|
| 15 |
|
236 |
|
| 16 |
}
|
237 |
}
|