<%-- Version: 2.0.0.0 Page: Client.jsp Copyright (c)2003 eShippers, Inc. --%> <%@ page import = "java.io.*" %> <%@ page import = "java.net.*" %> <% try { // Specify The Name And Path Of Remote Program URL url = new URL("http://www.intershipper.com/Interface/Intershipper/XML/v2.0/HTTP.jsp"); // Establish A URL Connection And Set Parameters URLConnection urlConn = url.openConnection(); urlConn.setDoInput(true); urlConn.setDoOutput(true); urlConn.setUseCaches(false); urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // Build Request String Via Key/Value Pairs String requestParameters = "Version=" + URLEncoder.encode("2.0.0.0") + "&ShipmentID=" + URLEncoder.encode("1234") + "&QueryID=" + URLEncoder.encode("YourQueryCode") + "&Username=" + URLEncoder.encode("YourUsername") + "&Password=" + URLEncoder.encode("YourPassword") + "&TotalCarriers=" + URLEncoder.encode("2") + "&CarrierCode1=" + URLEncoder.encode("UPS") + "&CarrierAccount1=" + URLEncoder.encode("123456789") + "&CarrierInvoiced1=" + URLEncoder.encode("1") + "&CarrierCode2=" + URLEncoder.encode("FDX") + "&CarrierAccount2=" + URLEncoder.encode("") + "&CarrierInvoiced2=" + URLEncoder.encode("0") + "&TotalClasses=" + URLEncoder.encode("3") + "&ClassCode1=" + URLEncoder.encode("1DY") + "&ClassCode2=" + URLEncoder.encode("2DY") + "&ClassCode3=" + URLEncoder.encode("GND") + "&DeliveryType=" + URLEncoder.encode("COM") + "&ShipMethod=" + URLEncoder.encode("DRP") + "&OriginationName=" + URLEncoder.encode("John Smith") + "&OriginationAddress1=" + URLEncoder.encode("123 Maple Lane") + "&OriginationAddress2=" + URLEncoder.encode("") + "&OriginationAddress3=" + URLEncoder.encode("") + "&OriginationCity=" + URLEncoder.encode("Phoenix") + "&OriginationState=" + URLEncoder.encode("AZ") + "&OriginationPostal=" + URLEncoder.encode("85345") + "&OriginationCountry=" + URLEncoder.encode("US") + "&DestinationName=" + URLEncoder.encode("Jane Doe") + "&DestinationAddress1=" + URLEncoder.encode("789 Oak Drive") + "&DestinationAddress2=" + URLEncoder.encode("Suite #410") + "&DestinationAddress3=" + URLEncoder.encode("Attention: Sales Department") + "&DestinationCity=" + URLEncoder.encode("Tempe") + "&DestinationState=" + URLEncoder.encode("AZ") + "&DestinationPostal=" + URLEncoder.encode("85282") + "&DestinationCountry=" + URLEncoder.encode("US") + "&Currency=" + URLEncoder.encode("USD") + "&TotalPackages=" + URLEncoder.encode("2") + "&BoxID1=" + URLEncoder.encode("YourBoxCode1") + "&Weight1=" + URLEncoder.encode("10") + "&WeightUnit1=" + URLEncoder.encode("LB") + "&Length1=" + URLEncoder.encode("10") + "&Width1=" + URLEncoder.encode("10") + "&Height1=" + URLEncoder.encode("10") + "&DimensionalUnit1=" + URLEncoder.encode("IN") + "&Packaging1=" + URLEncoder.encode("BOX") + "&Contents1=" + URLEncoder.encode("OTR") + "&Cod1=" + URLEncoder.encode("18500") + "&Insurance1=" + URLEncoder.encode("15000") + "&BoxID2=" + URLEncoder.encode("YourBoxCode2") + "&Weight2=" + URLEncoder.encode("20") + "&WeightUnit2=" + URLEncoder.encode("LB") + "&Length2=" + URLEncoder.encode("20") + "&Width2=" + URLEncoder.encode("20") + "&Height2=" + URLEncoder.encode("20") + "&DimensionalUnit2=" + URLEncoder.encode("IN") + "&Packaging2=" + URLEncoder.encode("BOX") + "&Contents2=" + URLEncoder.encode("OTR") + "&Cod2=" + URLEncoder.encode("0") + "&Insurance2=" + URLEncoder.encode("0") + "&TotalOptions=" + URLEncoder.encode("3") + "&OptionCode1=" + URLEncoder.encode("ADD") + "&OptionCode2=" + URLEncoder.encode("PDD") + "&OptionCode3=" + URLEncoder.encode("SDD"); // Send Request To Quote Engine Via HTTP Post DataOutputStream xmlRequest = new DataOutputStream(urlConn.getOutputStream()); xmlRequest.writeBytes(requestParameters); xmlRequest.flush(); xmlRequest.close(); // Get XML-Formatted Response From Quote Engine BufferedReader xmlResponse = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); // Handle XML-Formatted Response As Necessary String token = xmlResponse.readLine(); while (token != null) { out.print(token); token = xmlResponse.readLine(); } // Close Input Stream To Finalize Transaction xmlResponse.close(); } catch (MalformedURLException me) { System.err.println("MalformedURLException: " + me); } catch (IOException ioe) { System.err.println("IOException: " + ioe.getMessage()); } %>