No consigo llamar a una pagina externa desde un webservice, lo que necesito es enviarle un string :S
Código:
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.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();
Alguna sugerencia?