Posted By:
Zachary_Hunter
Posted On:
Wednesday, March 28, 2001 12:19 PM
Here's how to do it using just a URLConnection. It might not handle all the protocol specific errors, but should work fine fundimentally. Here's what you do:
//Create URL to post to
URL url = new URL("http://your.url.here");
//get connection to URL
URLConnection urlConn = url_.openConnection();
//prepare for writing request data
urlConn.setDoOutput(true);
//get output stream from URLCon
PrintWriter out = new PrintWriter(urlConn.getOutputStream());
//write the request data to stream
out.print(yourXMLRequestString);
//close the output connection
out.close();
//get response from post request
BufferedReader xmlIn = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
//prepare to read in content
StringBuffer response = new StringBuffer();
Strint line;
//read in all the xml
while((line = inXML.readLine()) != null)
{
response.append(sLine);
response.append("
");
}
Rather than reading the response into a StringBuffer, you could just use the input stream to create an InputSource to pass to a SAX parser's parse() method.