Duvida msg

1 resposta
D

dae galera…
to tentando chamar um web service atraves de um command mas ele ta retornando esse erro… alguem pode me explicar o q significa?

“Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.”

1 Resposta

M

Blz!

Eu tb estava com esse mesmo problema, dai utilizei thread junto e funcionou... me falaram que é pra evitar que o programa trave com o trafego da rede... :?:

public class HTTP implements Runnable{	
	String urlserver = "http://tua_url";
	String url = null ;
	String resultado = null ;
	HttpConnection connection = null;
	InputStream is = null;
	StringBuffer buffer = new StringBuffer();
		
	public void getpalavra (String buscar) throws IOException {
		Thread thread = new Thread(this);
		try {
			thread.start();			
		}catch(Exception e){	}
	}	
	
	public void run() {
		try {
			try {
				connection = (HttpConnection)Connector.open(url);
				connection.setRequestMethod(HttpConnection.GET);				
				is = connection.openDataInputStream();				
				if (connection.getResponseCode() == HttpConnection.HTTP_OK) {
					int ch = 0;
					while((ch = is.read()) != -1){
						buffer.append((char)ch);
					}		
					resultado = new String(buffer);
					System.out.println("resposta:\n"+ resultado + "\n");
				}
			}finally {
				if(is!= null) {
					is.close();
				}
				if(connection != null) {
					connection.close();
				}
			}
		}catch(IOException e){
			System.err.println("Erro na Conexão: " + e.toString());
		}
		
	}
}

Eu gostaria de saber como retornar alguma string a partir do que eu recebo do servido????... se alguém me ajudar eu agradeço.

Criado 16 de agosto de 2005
Ultima resposta 16 de ago. de 2005
Respostas 1
Participantes 2