Commit 740bf947 authored by msingh's avatar msingh

Added one method by Manish for RVB2B on 21/10/16


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@103774 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f5b196b1
...@@ -1425,6 +1425,89 @@ public class CommonWmsUtil { ...@@ -1425,6 +1425,89 @@ public class CommonWmsUtil {
} }
return responseShipTrack; return responseShipTrack;
} }
//Change by Manish on 20/10/16 for RVB2B [Start]
public String CallTrackShipStatusRvb2b(ShipmentStatus shipParams,String url,String login,String Password) throws Exception
{
String responseShipTrack = "";
try
{
if(url != null && url.length() > 0)
{
String urlParameters = GetUrlParameters(ShipmentStatus.class, shipParams);
System.out.println("URL: "+url);
System.out.println("urlParameters: "+urlParameters);
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
String loginPassword = login+ ":" + Password;
String encoded = new sun.misc.BASE64Encoder().encode (loginPassword.getBytes());
con.setRequestProperty ("Authorization", "Basic " + encoded);
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
con.setDoOutput(true);
try
{
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
}
catch(Exception e)
{
System.out.println("Exception in CommonWMS Util :: CallTrackShipStatus ::" + e.getMessage() + ":");
e.printStackTrace();
throw new Exception(e);
}
int responseCode = con.getResponseCode();
switch (responseCode) { //Capture the response code from server
case 500:
System.out.println("Unexpected server error.");
break;
case 404:
System.out.println("Target not found. Either files is missing or moved.");
break;
case 200: // if call successful, it may return 0 in case of product exist
StringBuilder response;
try
{
System.out.println("@@@@ in try bilock===");
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
response = new StringBuilder();
while ((inputLine = in.readLine()) != null)
{
System.out.println("@@@@ inputLine===");
response.append(inputLine);
}
responseShipTrack = response.toString();
System.out.println("Response From Ship Tracking Server ["+responseShipTrack+"]");
}
catch(Exception e)
{
System.out.println("Exception in CommonWMS Util :: CallTrackShipStatus ::" + e.getMessage() + ":");
e.printStackTrace();
throw new Exception(e);
}
break;
}
}
}catch (Exception e)
{
System.out.println("Exception in CommonWMS Util :: CallTrackShipStatus ::" + e.getMessage() + ":");
e.printStackTrace();
throw new Exception(e);
}
return responseShipTrack;
}
//Change by Manish on 20/10/16 for RVB2B [End]
static <T> String GetUrlParameters(Class<T> oObject, Object insObject) { static <T> String GetUrlParameters(Class<T> oObject, Object insObject) {
try { try {
Field[] fields = oObject.getDeclaredFields(); Field[] fields = oObject.getDeclaredFields();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment