2011-12-27 55 views
-2

我在j2me中用webservice創建了一個登錄頁面。但是在運行時我收到錯誤。任何人都可以幫忙嗎?我的代碼是:在j2me中調用庫jar文件時出現錯誤

public class Login extends MIDlet implements CommandListener { 



     //the main form 
     Form mainForm = null; 
     //the text-boxes for the input 
     TextField txtBoxA = null; 
     TextField txtBoxB = null; 
     //the result label 

     //the Exit command 
     Command cmdExit = null; 
     Command cmdAdd = null; 



     //the Display reference 
     Display display = null; 

     public Login() { 
     { 
      //construct the main form 
      mainForm = new Form("kSOAP Example"); 

      //construct the controls 
      txtBoxA = new TextField("UserName:", null, 50, TextField.ANY); 
      txtBoxB = new TextField("Password:", null, 50, TextField.ANY); 

      // result = new StringItem("Result:", null); 

      //add controls to the form 
      mainForm.append(txtBoxA); 
      mainForm.append(txtBoxB); 
      // mainForm.append(result); 

      //construct commands 
      cmdExit = new Command("Exit", Command.EXIT, 1); 
      cmdAdd = new Command("Add", Command.SCREEN, 1); 

      //add commands 
      mainForm.addCommand(cmdAdd); 
      mainForm.addCommand(cmdExit); 
     } 
     } 



     public void startApp() { 

      if (display == null) { 
       display = Display.getDisplay(this); 
      } 
      //display the main form 
      display.setCurrent(mainForm); 

      //register the command listener 
      mainForm.setCommandListener(this); 
     } 

     public void pauseApp() { 
     } 

     public void destroyApp(boolean unconditional) { 
     } 

     public void commandAction(Command c, Displayable d) { 

     if (c == cmdExit) { 
       this.destroyApp(false); 
       this.notifyDestroyed(); 
      } else if (c == cmdAdd) { 

       //callWebServiceMethod(); 

       Library lib=new Library(); 
       lib.init(); 

      } 
     } 

我的jar文件的編碼是library.jar

public class Library { 

      String METHOD_NAME = "ValidateLogin_M"; 
      String SOAP_ACTION ="http://64.244.69.235:81/MobileApp/ValidateLogin_M"; 
      String NAMESPACE ="http://64.244.69.235:81/MobileApp/"; 
      String URL ="http://64.244.69.235:81/MobileApp/service1.asmx"; 


     public Library() { 
      // TODO Auto-generated constructor stub 
     } 

     /** 
     * @param args 
     */ 
     public static void main(String[] args) { 
      // TODO Auto-generated method stub 

      Library lib=new Library(); 
      lib.init(); 

     } 

     public void init() 

     { 

      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

      String user= "[email protected]"; 
      String password= "123456"; 

      request.addProperty("UserID",user); 
      request.addProperty("Password",password); 

      SoapSerializationEnvelope envelope = 
        new SoapSerializationEnvelope(SoapEnvelope.VER11); 
      envelope.dotNet = true; 
      envelope.setOutputSoapObject(request); 

      HttpTransport j2meHttpTransport = new HttpTransport(URL); 

      try { 

       j2meHttpTransport.call(SOAP_ACTION, envelope); 
       SoapObject content = (SoapObject) envelope.bodyIn; 

       String sum = content.getProperty(0).toString(); 
       // result.setText(sum); 
        System.out.println("##########"+sum); 

        JSONArray jsonobj = new JSONArray(sum.toString()); 
          System.out.println("Json obj length:: " + jsonobj.length()); 
          if(jsonobj.length() == 0) 
          { 

          } 


          for(int i=0; i<jsonobj.length(); i++) 
          { 
           JSONObject jobj = jsonobj.getJSONObject(i); 

           String CustID = jobj.getString("CustID"); 
           System.out.println("CustID is :: "+CustID); 
           String Email = jobj.getString("Email"); 
           System.out.println("Email is :: "+Email); 
           String FirstName = jobj.getString("FirstName"); 
           System.out.println("FirstName is :: "+FirstName); 
           String LastName = jobj.getString("LastName"); 
           System.out.println("LastName is :: "+LastName); 
          } 


      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
      } 




     } 

我已導入jar文件,稱爲庫類。但我仍然有錯誤。

我的錯誤是

Starting emulator in execution mode 
Installing suite from: http://127.0.0.1:49412/WebApplication.jad 
TRACE: <at java.lang.Error: ClassFormatError: 56>, Exception caught in Display class 
java.lang.Error: ClassFormatError: 56 
    at com.web.application.Login.commandAction(Login.java:95) 
    at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46 
    at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74 
    at com.sun.midp.chameleon.layers.SoftButtonLayer.commandSelected(), bci=11 
    at com.sun.midp.chameleon.layers.MenuLayer.pointerInput(), bci=170 
    at com.sun.midp.chameleon.CWindow.pointerInput(), bci=76 
    at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handlePointerEvent(), bci=19 
    at com.sun.midp.lcdui.DisplayEventListener.process(), bci=296 
    at com.sun.midp.events.EventQueue.run(), bci=179 
    at java.lang.Thread.run(Thread.java:722) 
+1

已經回答CF HTTP ://stackoverflow.com/questions/1688257/classformaterror-56-while-using-hessian-in-j2me – 2011-12-27 05:52:56

回答

相關問題