!7 p { String xml = "" +"accountID" +"password" +"Jess" +"Speak to me"; URL u = new URL("https://cerevoice.com/rest/rest_1_1.php"); URLConnection uc = u.openConnection(); HttpURLConnection connection = (HttpURLConnection) uc; connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type","text/xml; charset=utf-8"); connection.setRequestProperty("Content-Length", String.valueOf(xml)); OutputStream out = connection.getOutputStream(); Writer wout = new OutputStreamWriter(out); wout.write(xml); wout.flush(); wout.close(); S result = utf8StreamToString(connection.getInputStream()); printIndent(result); /* Using your favourite Java XML Parser, parse the XML output, check that resultCode is equal to 1 and act accordingly */ }