I am writing a program in JAVA to POST a large number of XML Documents to a specific web address, in addition to a great deal of other data handling that is slightly unrelated to this question. The only trouble is, I'm expect to handle approximately 90,000 records. When POSTing an XML document, each record takes approximately 10 seconds, 9 of which is taken by receiving the response from the sever after POST.
My question is: Is there a way to POST data to a webserver, then ignore the server's response to save time?
Here is a snip of code that's giving me trouble, it takes approximate 9 seconds according to the system timer to go from "writer.close" to "con.getResponseCode()"
URL url = new URL(TargetURL);
con = (HttpsURLConnection) url.openConnection();
//Login with given credentials
String login = (Username)+":"+(Password);
String encoding = new sun.misc.BASE64Encoder().encode(login.getBytes());
con.setRequestProperty ("Authorization", "Basic " + encoding);
// specify that we will send output and accept input
con.setRequestMethod("POST");
con.setDoInput(true);
con.setDoOutput(true);
con.setConnectTimeout(20000) ; // long timeout, but not infinite
con.setReadTimeout(20000);
con.setUseCaches (false);
con.setDefaultUseCaches (false);
// tell the web server what we are sending
con.setRequestProperty ( "Content-Type", "text/xml" );
OutputStreamWriter writer = new OutputStreamWriter( con.getOutputStream() );
writer.write(data);
writer.flush();
writer.close();
//****This is our problem.*****//
int result = con.getResponseCode();
System.err.println( "\nResponse from server after POST:\n" + result );