public static HttpResponse executePutRequest(String serviceEndPoint,String payLoad,boolean secure) throws IOException {
  URL url=(secure) ? new URL(SERVICE_ROOT_URI + "secure/" + serviceEndPoint) : new URL(SERVICE_ROOT_URI + serviceEndPoint);
  HttpURLConnection connection=(HttpURLConnection)url.openConnection();
  try {
    connection.setRequestMethod("PUT");
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setUseCaches(false);
    if (secure) {
      connection.setRequestProperty("Authorization",AUTHORIZATION);
    }
    connection.setRequestProperty("Content-Type","application/xml");
    connection.setRequestProperty("Accept","application/xml");
    DataOutputStream outStream=new DataOutputStream(connection.getOutputStream());
    try {
      outStream.writeBytes(payLoad);
      outStream.close();
      return new HttpResponse(connection);
    }
  finally {
      outStream.close();
    }
  }
  finally {
    connection.disconnect();
  }
}

public static HttpResponse executePutRequest ( String serviceEndPoint , String payLoad , boolean secure ) throws IOException { URL url = ( secure ) ? new URL ( SERVICE_ROOT_URI + "secure/" + serviceEndPoint ) : new URL ( SERVICE_ROOT_URI + serviceEndPoint ) ; HttpURLConnection connection = ( HttpURLConnection ) url . openConnection ( ) ; try { connection . setRequestMethod ( "PUT" ) ; connection . setDoInput ( true ) ; connection . setDoOutput ( true ) ; connection . setUseCaches ( false ) ; if ( secure ) { connection . setRequestProperty ( "Authorization" , AUTHORIZATION ) ; } connection . setRequestProperty ( "Content-Type" , "application/xml" ) ; connection . setRequestProperty ( "Accept" , "application/xml" ) ; DataOutputStream outStream = new DataOutputStream ( connection . getOutputStream ( ) ) ; try { outStream . writeBytes ( payLoad ) ; outStream . close ( ) ; return new HttpResponse ( connection ) ; } finally { outStream . close ( ) ; } } finally { connection . disconnect ( ) ; } }
helper method to execute a http put request
