Subversion Repositories SmartDukaan

Rev

Rev 7908 | Rev 8395 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7908 Rev 7925
Line 1... Line 1...
1
package com;
1
package com;
2
 
2
 
3
import in.shop2020.config.ConfigException;
-
 
4
import in.shop2020.thrift.clients.config.ConfigClient;
-
 
5
 
-
 
6
import com.fedex.track.stub.*;
3
import com.fedex.track.stub.*;
7
 
4
 
8
 
5
 
9
/** 
6
/** 
10
 * Demo of using the Track service with Axis 
7
 * Demo of using the Track service with Axis 
Line 18... Line 15...
18
 * This sample code has been tested with JDK 5 and Apache Axis 1.4
15
 * This sample code has been tested with JDK 5 and Apache Axis 1.4
19
 */
16
 */
20
public class TrackWebServiceClient {
17
public class TrackWebServiceClient {
21
	
18
	
22
	
19
	
23
	public static TrackReply getTrackingUpdates(String trackingNumber){
20
	public static TrackReply getTrackingUpdates(String trackingNumber, ClientDetail clientDetail, WebAuthenticationDetail wac, String endpointAddress){
24
		TrackRequest request = new TrackRequest();
21
		TrackRequest request = new TrackRequest();
25
 
22
 
26
        request.setClientDetail(createClientDetail());
23
        request.setClientDetail(clientDetail);
27
        request.setWebAuthenticationDetail(createWebAuthenticationDetail());
24
        request.setWebAuthenticationDetail(wac);
28
        
25
        
29
        TransactionDetail transactionDetail = new TransactionDetail();
26
        TransactionDetail transactionDetail = new TransactionDetail();
30
        transactionDetail.setCustomerTransactionId("Tracking Request"); 
27
        transactionDetail.setCustomerTransactionId("Tracking Request"); 
31
        request.setTransactionDetail(transactionDetail);
28
        request.setTransactionDetail(transactionDetail);
32
 
29
 
Line 44... Line 41...
44
        	// Initializing the service
41
        	// Initializing the service
45
			TrackServiceLocator service;
42
			TrackServiceLocator service;
46
			TrackPortType port;
43
			TrackPortType port;
47
			
44
			
48
			service = new TrackServiceLocator();
45
			service = new TrackServiceLocator();
49
			updateEndPoint(service);
46
			updateEndPoint(service,endpointAddress);
50
			port = service.getTrackServicePort();
47
			port = service.getTrackServicePort();
51
		    
48
		    
52
			reply = port.track(request); // This is the call to the web service passing in a request object and returning a reply object
49
			reply = port.track(request); // This is the call to the web service passing in a request object and returning a reply object
53
			
50
			
54
			printNotifications(reply.getNotifications());
51
			printNotifications(reply.getNotifications());
Line 73... Line 70...
73
			notificationSeverityType.equals(NotificationSeverityType.SUCCESS)) {
70
			notificationSeverityType.equals(NotificationSeverityType.SUCCESS)) {
74
			return true;
71
			return true;
75
		}
72
		}
76
 		return false;
73
 		return false;
77
	}
74
	}
78
    
-
 
79
 
-
 
80
	private static ClientDetail createClientDetail() {
-
 
81
        ClientDetail clientDetail = new ClientDetail();
-
 
82
        String accountNumber ="";
-
 
83
		try {
-
 
84
			accountNumber = ConfigClient.getClient().get("fedex_account_number");
-
 
85
		} catch (ConfigException e) {
-
 
86
			// TODO Auto-generated catch block
-
 
87
			e.printStackTrace();
-
 
88
			
-
 
89
		}
-
 
90
		
-
 
91
        String meterNumber ="";
-
 
92
		try {
-
 
93
			meterNumber = ConfigClient.getClient().get("fedex_meter_number");
-
 
94
		} catch (ConfigException e) {
-
 
95
			// TODO Auto-generated catch block
-
 
96
			e.printStackTrace();
-
 
97
		}
-
 
98
        
-
 
99
		/*if (accountNumber == null) {
-
 
100
    	accountNumber = "510087089"; // Replace "XXX" with clients account number
-
 
101
	    }
-
 
102
	    if (meterNumber == null) {
-
 
103
	    	meterNumber = "118585428"; // Replace "XXX" with clients meter number
-
 
104
	    }*/
-
 
105
		
-
 
106
        clientDetail.setAccountNumber(accountNumber);
-
 
107
        clientDetail.setMeterNumber(meterNumber);
-
 
108
        return clientDetail;
-
 
109
	}
-
 
110
	
-
 
111
	private static WebAuthenticationDetail createWebAuthenticationDetail() {
-
 
112
        WebAuthenticationCredential wac = new WebAuthenticationCredential();
-
 
113
        String key="";
-
 
114
		try {
-
 
115
			key = ConfigClient.getClient().get("fedex_authenication_key");
-
 
116
		} catch (ConfigException e) {
-
 
117
			// TODO Auto-generated catch block
-
 
118
			e.printStackTrace();
-
 
119
		}
-
 
120
		
75
		
121
        String password="";
-
 
122
		try {
-
 
123
			password = ConfigClient.getClient().get("fedex_authenication_password");
-
 
124
		} catch (ConfigException e) {
-
 
125
			// TODO Auto-generated catch block
-
 
126
			e.printStackTrace();
-
 
127
		}
-
 
128
       
-
 
129
		
-
 
130
		/*if (key == null) {
-
 
131
    	key = "4XqfCFRFM4uXe6Wm"; // Replace "XXX" with clients key
-
 
132
	    }
-
 
133
	    if (password == null) {
-
 
134
	    	password = "LtIgtKmluqOPikdNmTjXWPkTo"; // Replace "XXX" with clients password
-
 
135
	    }*/
-
 
136
        wac.setKey(key);
-
 
137
        wac.setPassword(password);
-
 
138
		return new WebAuthenticationDetail(wac);
-
 
139
	}
-
 
140
		
-
 
141
	private static void updateEndPoint(TrackServiceLocator serviceLocator) {
76
	private static void updateEndPoint(TrackServiceLocator serviceLocator, String endPoint) {
142
		String endPoint="";
-
 
143
		try {
-
 
144
			endPoint = ConfigClient.getClient().get("fedex_endpoint_address_track");
-
 
145
		} catch (ConfigException e) {
-
 
146
			// TODO Auto-generated catch block
-
 
147
			e.printStackTrace();
-
 
148
		}
-
 
149
		if (endPoint != null) {
77
		if (endPoint != null) {
150
			serviceLocator.setTrackServicePortEndpointAddress(endPoint);
78
			serviceLocator.setTrackServicePortEndpointAddress(endPoint);
151
		}
79
		}
152
	}
80
	}
153
	
81