Commit 7ac8cb16 authored by dpawar's avatar dpawar

check shipping url null or not


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99272 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 51033634
...@@ -1262,56 +1262,27 @@ public class CommonWmsUtil { ...@@ -1262,56 +1262,27 @@ public class CommonWmsUtil {
{ {
try try
{ {
String urlParameters = GetUrlParameters(ShipmentStatus.class, shipParams); if(url != null && url.length() > 0)
System.out.println("URL: "+url);
System.out.println("urlParameters: "+urlParameters);
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//add reuqest header
con.setRequestMethod("POST"); //Always do the POST method
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
// Send post request
con.setDoOutput(true);
try
{ {
DataOutputStream wr = new DataOutputStream(con.getOutputStream()); String urlParameters = GetUrlParameters(ShipmentStatus.class, shipParams);
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(); System.out.println("URL: "+url);
System.out.println("urlParameters: "+urlParameters);
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
switch (responseCode) { //Capture the response code from server //add reuqest header
case 500: con.setRequestMethod("POST"); //Always do the POST method
System.out.println("Unexpected server error."); con.setRequestProperty("User-Agent", "Mozilla/5.0");
break; con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
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;
// Send post request
con.setDoOutput(true);
try try
{ {
BufferedReader in = new BufferedReader( DataOutputStream wr = new DataOutputStream(con.getOutputStream());
new InputStreamReader(con.getInputStream())); wr.writeBytes(urlParameters);
String inputLine; wr.flush();
response = new StringBuilder();
while ((inputLine = in.readLine()) != null)
{
response.append(inputLine);
}
System.out.println("Response From Ship Tracking Server ["+response.toString()+"]");
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -1320,8 +1291,41 @@ public class CommonWmsUtil { ...@@ -1320,8 +1291,41 @@ public class CommonWmsUtil {
throw new Exception(e); throw new Exception(e);
} }
break; 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
{
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
response = new StringBuilder();
while ((inputLine = in.readLine()) != null)
{
response.append(inputLine);
}
System.out.println("Response From Ship Tracking Server ["+response.toString()+"]");
}
catch(Exception e)
{
System.out.println("Exception in CommonWMS Util :: CallTrackShipStatus ::" + e.getMessage() + ":");
e.printStackTrace();
throw new Exception(e);
}
break;
}
} }
}catch (Exception e) }catch (Exception e)
{ {
System.out.println("Exception in CommonWMS Util :: CallTrackShipStatus ::" + e.getMessage() + ":"); System.out.println("Exception in CommonWMS Util :: CallTrackShipStatus ::" + e.getMessage() + ":");
......
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