Eai galera.....preciso executar uma servlet de um JFRAME...Esta minha servlet é um Web Script.....aquelas servlets que executam javascripts no servidor!!!
por exemplo:
http://localhost:8080/alfresco/command/script/execute?scriptPath=/Company%20Home/listActions.js
Eu passo o parametro scriptPath, onde se encontra o javascript listActions
Já tentei:
String hostname = null;
String autentica = "admin:admin";
try {
hostname = "localhost";
String data = URLEncoder.encode("scriptPath", "UTF-8") + "=" + URLEncoder.encode("/Company%20Home/Teste/workflow.js", "UTF-8");
int port = 8080;
InetAddress addr = InetAddress.getByName(hostname);
Socket socket = new Socket(addr, port);
String path = "/alfresco/command/script/execute";
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF8"));
wr.write("POST "+path+" HTTP/1.0\r\n");
wr.write("Proxy-Authorization: Basic "
+ new sun.misc.BASE64Encoder().encode(
autentica.getBytes())
+ "\r\n\r\n");
wr.write("Content-Length: "+data.length()+"\r\n");
wr.write("Content-Type: application/x-www-form-urlencoded\r\n");
wr.write("\r\n");
wr.write(data);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(rd.readLine());
}
wr.close();
rd.close();
//wf.fechaSessao();
}catch ( UnknownHostException eh )
{
eh.printStackTrace();
System.exit( 1 ) ;
}
Quando eu executo (no log) dá acesso negado....provavelmente precisa ser feita uma autenticação.....mas não consigo implementar
wr.write("Proxy-Authorization: Basic "+ new sun.misc.BASE64Encoder().encode(autentica.getBytes())+"\r\n\r\n");
direito....alguem tem alguma solução?
Vlw