Boa tarde pessoal. Bom minha dúvida é a seguinte. Fiz um projeto simples no netbeans onde eu crio um serviço web e um aplicativo móvel para consumir ele. Está funcionando normal no netbeans. Agora queria testar ele em um celular mas não estou conseguindo. O que eu teria que modificar dentro do meu aplicativo? Estou usando glassfish para meu servidor web.
Seguem os códigos:
Midlet:
[code]package servico;
import java.rmi.RemoteException;
import javax.microedition.lcdui.;
import javax.microedition.midlet.;
public class MeuMidlet extends MIDlet implements CommandListener{
TextField txtNum1, txtNum2, txtNum3;
StringItem strResultado;
Command cmdSend;
Display display;
Form tela;
Servico_Stub sws = new Servico_Stub();
int soma;
public MeuMidlet(){
txtNum1 = new TextField(“Número 1:”, null, 10, TextField.NUMERIC);
txtNum2 = new TextField(“Número 2:”, null, 10, TextField.NUMERIC);
txtNum3 = new TextField(“Número 3:”, null, 10, TextField.NUMERIC);
cmdSend = new Command(“Somar”, Command.SCREEN, 0 );
strResultado = new StringItem("Resultado: ", “0”);
display = Display.getDisplay( this );
tela = new Form(“Chamando Web Service”);
tela.append( txtNum1 );
tela.append( txtNum2 );
tela.append( txtNum3 );
tela.append( strResultado );
tela.addCommand( cmdSend );
}
public void startApp(){
display = Display.getDisplay(this);
display.setCurrent( tela );
tela.setCommandListener(this);
}
public void pauseApp(){
}
public void destroyApp(boolean b){
display.setCurrent( null );
this.notifyDestroyed();
}
public void commandAction( Command command, Displayable displayable){
if ( command == cmdSend )
{
Thread th = new Thread(){
public void run(){
try {
soma = sws.soma(Integer.parseInt(txtNum1.getString()),Integer.parseInt(txtNum2.getString()),Integer.parseInt(txtNum3.getString()));
} catch (RemoteException ex) {
ex.printStackTrace();
}
strResultado.setText(String.valueOf(soma));
}
};
th.start();
}
}
}
[/code]
Serviço:
package servico;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
/**
*
* @author fernando
*/
@WebService()
public class Servico {
/**
* Operação de serviço web
*/
@WebMethod(operationName = "soma")
public int soma(@WebParam(name = "i")
int i, @WebParam(name = "j")
int j, @WebParam(name = "k")
int k) {
return i + j + k;
}
}