Retroceder   Foros del Web > Programación para sitios web > Java y JSP

Respuesta
 
Herramientas Desplegado
Antiguo 03-jun-2008, 09:23   #1 (permalink)
coolz41 ha deshabilitado el karma
 
Fecha de Ingreso: abril-2008
Mensajes: 6
Acceder al xml de un servicio web

Hola queria preguntaros como accedeis al xml de un servicio web, yo hasta ahora estoy usando httpclient pero me da errores de vez en cuando. Lo hago asi:

public class ObtenerXML {


public static String realizarAccion(String url) throws HttpException {

String responseBody = null;

// Create an instance of HttpClient.
HttpClient client = new HttpClient();
//client.getParams().setParameter("http.protocol.con tent-charset", "UTF-8");


// Create a method instance.
GetMethod method = new GetMethod(url);

// Provide custom retry handler is necessary
method.getParams().setParameter(HttpMethodParams.R ETRY_HANDLER,
new DefaultHttpMethodRetryHandler(3, false));
// method.getParams().setParameter("http.protocol.con tent-charset", "UTF-8");


try {
// Execute the method.
int statusCode = client.executeMethod(method);

if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + method.getStatusLine());
}

// Read the response body.
responseBody = method.getResponseBodyAsString();

// Deal with the response.
// Use caution: ensure correct character encoding and is not binary data


} catch (HttpException e) {
System.err.println("Fatal protocol violation: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.err.println("Fatal transport error: " + e.getMessage());
e.printStackTrace();
} finally {
// Release the connection.
method.releaseConnection();
}

return ((responseBody));
}

}

Si conoceis alguna forma mas eficiente de hacerlo os lo agrdeceria.

Muchas gracias!!
coolz41 está desconectado   Responder Citando
Antiguo 03-jun-2008, 17:51   #2 (permalink)
/** @package Moderador */
jam1138 llegará a ser famoso muy prontojam1138 llegará a ser famoso muy prontojam1138 llegará a ser famoso muy pronto
 
Avatar de jam1138
 
Fecha de Ingreso: julio-2004
Ubicación: sèveR led onieR lE
Mensajes: 7.822
Respuesta: Acceder al xml de un servicio web

... y eso es... JAVA. Tema movido.
__________________
» ¿Cómo hacer preguntas inteligentes? «
jam1138 está desconectado   Responder Citando
Respuesta
No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Desactivado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 10:16.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93