Foros del Web » Programación para mayores de 30 ;) » Java »

LLamar a un asp o jsp externo desde un Webservice?

Estas en el tema de LLamar a un asp o jsp externo desde un Webservice? en el foro de Java en Foros del Web. Hola, tengo el siguiente problema. No consigo llamar a una pagina externa desde un webservice, lo que necesito es enviarle un string :S Código: InputStreamReader ...
  #1 (permalink)  
Antiguo 18/01/2011, 09:36
 
Fecha de Ingreso: abril-2008
Mensajes: 15
Antigüedad: 16 años
Puntos: 0
LLamar a un asp o jsp externo desde un Webservice?

Hola, tengo el siguiente problema.

No consigo llamar a una pagina externa desde un webservice, lo que necesito es enviarle un string :S

Código:
InputStreamReader isr = null;
			try {
				isr = new InputStreamReader(new ByteArrayInputStream(new StringBuffer(xmlOut).toString().getBytes("UTF-8")));
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		       BufferedReader br = new BufferedReader(isr);
		       String line;
		       Writer writer = new StringWriter();
				try {
					char[] buffer = new char[1024];
					int n;
					while ((n = br.read(buffer)) != -1) {
						writer.write(buffer, 0, n);					
					}
					line = writer.toString();
			        URL url = null;
					try {

						url = new URL( "http://localhost:7001/AdaptorWAR/index5.jsp");
					} catch (MalformedURLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}

					URLConnection connection = url.openConnection();
					connection.setDoOutput(true) ;
					connection.setRequestProperty("Content-type","text/xml");
					// The order in which input and output strams are acquired matters.
					OutputStreamWriter os = new OutputStreamWriter(connection.getOutputStream());
					//ObjectOutputStream os = new ObjectOutputStream( connection.getOutputStream() );
					os.write(URLDecoder.decode(line, "UTF-8").toString()) ;
					os.flush();
					os.close() ;
					
				  OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
				  
				  
				  os.write(line);
				  out.close();
la cuestion es que sin el outputstreamwriter no me va a la jsp y con el me hace todo bien pero vuelvo al webservice denuevo.

Alguna sugerencia?

Etiquetas: asp, externo, jsp, llamar, webservice
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:14.