[ Valerij Zajcev @ 26.01.2009. 09:26 ] @
Kada treba da se povezem na neku drugu metodu recimo neka koja vraca samo string ono radi ok. Ali ova metoda mora da posalje dva parametra na WS i da na osnovu njih vrati 'string'. Problem nastaje kada u text polja ukucam username i password program me pita "...bla...bla...want's to connect to http://www......asmx using airtime. This may result in charges. Is it OK to use airtime?", ja tu kazem 'Yes' i tu se aplikacija zaustavi, nista se ne desava dalje. Sta sam uradio? Code: import java.rmi.RemoteException; import javax.xml.rpc.Stub; import javax.microedition.lcdui.*; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import com.game.web.ServiceSoap_Stub; public class HelloWorld3 extends MIDlet implements CommandListener { private String webServiceURL = "http://localhost/javaGame/Service.asmx"; private Command exitCommand; private String userDataString = ""; private Display display; private TextField userName,password; public Form form; private Command login,cancel; public HelloWorld3() { exitCommand = new Command("Exit", Command.EXIT, 0); form = new Form("Sign in"); userName = new TextField("LoginID:", "", 30, TextField.ANY); password = new TextField("Password:", "", 30, TextField.PASSWORD); cancel = new Command("Cancel", Command.CANCEL, 2); login = new Command("Login", Command.OK, 2); } public void startApp() { display = Display.getDisplay(this); form.append(userName); form.append(password); form.addCommand(cancel); form.addCommand(login); form.setCommandListener(this); display.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { notifyDestroyed(); } public void commandAction(Command c, Displayable s) { String label = c.getLabel(); if(label.equals("Cancel")) { destroyApp(true); } else if(label.equals("Login")) { validateUser(userName.getString(), password.getString()); } } public void validateUser(String name, String password) { try{ ServiceSoap_Stub service = new ServiceSoap_Stub(); service._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, webServiceURL); service._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, Boolean.FALSE); userDataString = service.loginUser(name, password); if (userDataString != ""){ showMsg(); } else{ tryAgain(); } } catch(RemoteException e){ } } public void showMsg() { Alert success = new Alert("Your Login Process is completed!"); userName.setString(""); password.setString(""); display.setCurrent(success, form); } public void tryAgain() { Alert error = new Alert("Please try again"); error.setTimeout(900); userName.setString(""); password.setString(""); display.setCurrent(error, form); } } |