Thread View: es.comp.lenguajes.java
3 messages
3 total messages
Started by Juanjo
Mon, 12 Feb 2007 21:47
XML y metodo POST
Author: Juanjo
Date: Mon, 12 Feb 2007 21:47
Date: Mon, 12 Feb 2007 21:47
9 lines
1169 bytes
1169 bytes
Necesito mandar un XML desde una aplicacion java a una ubicacion remota usando el metodo POST y no encuentro (o no se buscar) el ejemplo que me lo aclare. Me podeis dar una pista. Gracias. Juanjo.
Re: XML y metodo POST
Author: Eduardo Yáñez Parareda
Date: Tue, 13 Feb 2007 08:36
Date: Tue, 13 Feb 2007 08:36
23 lines
1684 bytes
1684 bytes
try {
// Construct data
String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
data += "&" + URLEncoder.encode("key2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
// Send data
URL url = new URL("http://hostname:80/cgi");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
// Process line...
}
wr.close();
rd.close();
} catch (Exception e) {
}
Re: XML y metodo POST
Author: Juanjo
Date: Tue, 13 Feb 2007 09:08
Date: Tue, 13 Feb 2007 09:08
3 lines
1058 bytes
1058 bytes
Gracias. Lo probar�. Juanjo
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads