function DoPOST() { URL url = new URL("https://secure.leadexec.net/LeadReceiver"); String document = "<Leads vid='1234' lid='1234' aid='1234'> <Lead reference='ABC1234'> <FirstName>Test</FirstName> <LastName>ing</LastName> <Email>noemail@lead.com</Email> </Lead> </Leads>"; FileReader fr = new FileReader(document); char[] buffer = new char[1024*10]; int b_read = 0; if ((b_read = fr.read(buffer)) != -1) { URLConnection urlc = url.openConnection(); urlc.setRequestProperty("Content-Type","text/xml"); urlc.setDoOutput(true); urlc.setDoInput(true); PrintWriter pw = new PrintWriter(urlc.getOutputStream()); pw.write(buffer, 0, b_read); pw.close(); BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream())); String inputLine; while ((res_line = in.readLine()) != null) System.out.println(res_line); in.close(); } }In the example above, the example POST XML is first generated and then is sent through the request stream to the POST URL. The response is then received and would then be processed to determined the desired action depending on the sending page's requirements and method sent to.
Copyright ©2024 ClickPoint Software