Foros del Web

Foros del Web (http://www.forosdelweb.com/)
-   Java (http://www.forosdelweb.com/f45/)
-   -   Acceder al xml de un servicio web (http://www.forosdelweb.com/f45/acceder-xml-servicio-web-592892/)

coolz41 03/06/2008 09:23

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!!

jam1138 03/06/2008 17:51

Respuesta: Acceder al xml de un servicio web
 
... y eso es... JAVA. Tema movido.
:adios:


La zona horaria es GMT -6. Ahora son las 07:40.

Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.