public static String sendUpsRequest(String upsService,String xmlString,String shipmentGatewayConfigId,String resource,Delegator delegator,Locale locale) throws UpsConnectException {
  String conStr=getShipmentGatewayConfigValue(delegator,shipmentGatewayConfigId,"connectUrl",resource,"shipment.ups.connect.url");
  if (conStr == null) {
    throw new UpsConnectException(UtilProperties.getMessage(resourceError,"FacilityShipmentUpsIncompleteConnectionURL",locale));
  }
  if (upsService == null) {
    throw new UpsConnectException(UtilProperties.getMessage(resourceError,"FacilityShipmentUpsServiceNameCannotBeNull",locale));
  }
  if (xmlString == null) {
    throw new UpsConnectException(UtilProperties.getMessage(resourceError,"FacilityShipmentUpsXmlMessageCannotBeNull",locale));
  }
  conStr=conStr.trim();
  if (!conStr.endsWith("/")) {
    conStr=conStr + "/";
  }
  conStr=conStr + upsService;
  String timeOutStr=getShipmentGatewayConfigValue(delegator,shipmentGatewayConfigId,"connectTimeout",resource,"shipment.ups.connect.timeout","60");
  int timeout=60;
  try {
    timeout=Integer.parseInt(timeOutStr);
  }
 catch (  NumberFormatException e) {
    Debug.logError(e,"Unable to set timeout to " + timeOutStr + " using default "+ timeout);
  }
  HttpClient http=new HttpClient(conStr);
  http.setTimeout(timeout * 1000);
  http.setAllowUntrusted(true);
  String response=null;
  try {
    response=http.post(xmlString);
  }
 catch (  HttpClientException e) {
    Debug.logError(e,"Problem connecting with UPS server [" + conStr + "]",module);
    throw new UpsConnectException(UtilProperties.getMessage(resourceError,"FacilityShipmentUpsURLConnectionProblem",UtilMisc.toMap("exception",e),locale));
  }
  if (response == null) {
    throw new UpsConnectException(UtilProperties.getMessage(resourceError,"FacilityShipmentUpsReceivedNullResponse",locale));
  }
  if (Debug.verboseOn())   Debug.logVerbose("UPS Response : " + response,module);
  return response;
}

public static String sendUpsRequest ( String upsService , String xmlString , String shipmentGatewayConfigId , String resource , Delegator delegator , Locale locale ) throws UpsConnectException { String conStr = getShipmentGatewayConfigValue ( delegator , shipmentGatewayConfigId , "connectUrl" , resource , "shipment.ups.connect.url" ) ; if ( conStr == null ) { throw new UpsConnectException ( UtilProperties . getMessage ( resourceError , "FacilityShipmentUpsIncompleteConnectionURL" , locale ) ) ; } if ( upsService == null ) { throw new UpsConnectException ( UtilProperties . getMessage ( resourceError , "FacilityShipmentUpsServiceNameCannotBeNull" , locale ) ) ; } if ( xmlString == null ) { throw new UpsConnectException ( UtilProperties . getMessage ( resourceError , "FacilityShipmentUpsXmlMessageCannotBeNull" , locale ) ) ; } conStr = conStr . trim ( ) ; if ( ! conStr . endsWith ( "/" ) ) { conStr = conStr + "/" ; } conStr = conStr + upsService ; String timeOutStr = getShipmentGatewayConfigValue ( delegator , shipmentGatewayConfigId , "connectTimeout" , resource , "shipment.ups.connect.timeout" , "60" ) ; int timeout = 60 ; try { timeout = Integer . parseInt ( timeOutStr ) ; } catch ( NumberFormatException e ) { Debug . logError ( e , "Unable to set timeout to " + timeOutStr + " using default " + timeout ) ; } HttpClient http = new HttpClient ( conStr ) ; http . setTimeout ( timeout * 1000 ) ; http . setAllowUntrusted ( true ) ; String response = null ; try { response = http . post ( xmlString ) ; } catch ( HttpClientException e ) { Debug . logError ( e , "Problem connecting with UPS server [" + conStr + "]" , module ) ; throw new UpsConnectException ( UtilProperties . getMessage ( resourceError , "FacilityShipmentUpsURLConnectionProblem" , UtilMisc . toMap ( "exception" , e ) , locale ) ) ; } if ( response == null ) { throw new UpsConnectException ( UtilProperties . getMessage ( resourceError , "FacilityShipmentUpsReceivedNullResponse" , locale ) ) ; } if ( Debug . verboseOn ( ) ) Debug . logVerbose ( "UPS Response : " + response , module ) ; return response ; }
opens a url to ups and makes a request .
