Hi All,
I am passing an XML
String through HTTPURLConnection to the server which is an HP Unix machine. First time request and response goes through. For the second time when i access the server outputstream is posing a problem. A null pointer exception is thrown and the passed XML string length is zero.
Immediate response will be greatly appreciated.
Here is the code snippet.
try
{
URL url = new URL(url_resource);
con = (HttpURLConnection) url.openConnection();
con.setUseCaches( false );
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty( "Content-Length", String.valueOf( xml_string.length() ) );
con.setRequestProperty( "Content-Type", "multi-part/form-data");
}
catch(Exception exc)
{
String s = exc.getMessage();
}
try
{
// Write out the XML Contents
PrintWriter out = new PrintWriter(new OutputStreamWriter(con.getOutputStream() ));
out.println(xml_buff.toString());
out.close();
}
catch(Exception exc1)
{
String s = exc1.getMessage();
}
After this When I try to read the message from the input stream NullPointerException is thrown and the message is as "Did not meet stated content length of OutputStream: you wrote 0 bytes and I was expecting you to write exactly 252 bytes!!!"
Regards