2011-01-27 86 views
0

下面的代碼看起來如何崩潰我的應用程序ksoap2 101

不知道爲什麼

幫助表示讚賞。

final String SOAP_ACTION = "http://tempuri.org/MyFunction"; 
    final String METHOD_NAME = "MyFunction"; 
    final String NAMESPACE = "http://tempuri.org/"; 
    final String URL = "http://localhost:23250/WS1.asmx"; 
    final SoapObject requestObject = new SoapObject(NAMESPACE, METHOD_NAME); 
    requestObject.addProperty("UserIdentifier", ""); 
    requestObject.addProperty("PhoneIdentifier", ""); 

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

    try 
    { 
     HttpTransport androidHttpTransport = new HttpTransport(URL); 
     androidHttpTransport.call(SOAP_ACTION, envelope); 
     SoapObject response = (SoapObject)envelope.getResponse(); 
     String result = response.getProperty(0).toString(); 
    } 
    catch(Exception e) 
    { 
     e.printStackTrace(); 
    } 

我可以打電話從我的瀏覽器就好

下面的Web服務是logcat的數據

01-27 09:29:49.564: DEBUG/dalvikvm(296): GC_EXPLICIT freed 307 objects/16416 bytes in 169ms 
01-27 09:29:55.555: INFO/ActivityManager(106): Starting activity: Intent { cmp=myapp.android.v2/.myPage } 
01-27 09:29:56.035: INFO/dalvikvm(1074): Could not find method javax.microedition.io.Connector.open, referenced from method org.ksoap2.transport.ServiceConnectionMidp.<init> 
01-27 09:29:56.035: WARN/dalvikvm(1074): VFY: unable to resolve static method 113: Ljavax/microedition/io/Connector;.open (Ljava/lang/String;IZ)Ljavax/microedition/io/Connection; 
01-27 09:29:56.035: DEBUG/dalvikvm(1074): VFY: replacing opcode 0x71 at 0x0005 
01-27 09:29:56.035: DEBUG/dalvikvm(1074): VFY: dead code 0x0008-000d in Lorg/ksoap2/transport/ServiceConnectionMidp;.<init> (Ljava/lang/String;)V 
01-27 09:29:56.055: INFO/dalvikvm(1074): Could not find method javax.microedition.io.HttpConnection.close, referenced from method org.ksoap2.transport.ServiceConnectionMidp.disconnect 
01-27 09:29:56.055: WARN/dalvikvm(1074): VFY: unable to resolve interface method 114: Ljavax/microedition/io/HttpConnection;.close()V 
01-27 09:29:56.065: DEBUG/dalvikvm(1074): VFY: replacing opcode 0x72 at 0x0002 
01-27 09:29:56.065: DEBUG/dalvikvm(1074): VFY: dead code 0x0005-0005 in Lorg/ksoap2/transport/ServiceConnectionMidp;.disconnect()V 
01-27 09:29:56.085: INFO/dalvikvm(1074): Could not find method javax.microedition.io.HttpConnection.openInputStream, referenced from method org.ksoap2.transport.ServiceConnectionMidp.openInputStream 
01-27 09:29:56.085: WARN/dalvikvm(1074): VFY: unable to resolve interface method 115: Ljavax/microedition/io/HttpConnection;.openInputStream()Ljava/io/InputStream; 
01-27 09:29:56.085: DEBUG/dalvikvm(1074): VFY: replacing opcode 0x72 at 0x0002 
01-27 09:29:56.095: DEBUG/dalvikvm(1074): VFY: dead code 0x0005-0006 in Lorg/ksoap2/transport/ServiceConnectionMidp;.openInputStream()Ljava/io/InputStream; 
01-27 09:29:56.115: INFO/dalvikvm(1074): Could not find method javax.microedition.io.HttpConnection.openOutputStream, referenced from method org.ksoap2.transport.ServiceConnectionMidp.openOutputStream 
01-27 09:29:56.115: WARN/dalvikvm(1074): VFY: unable to resolve interface method 116: Ljavax/microedition/io/HttpConnection;.openOutputStream()Ljava/io/OutputStream; 
01-27 09:29:56.115: DEBUG/dalvikvm(1074): VFY: replacing opcode 0x72 at 0x0002 
01-27 09:29:56.115: DEBUG/dalvikvm(1074): VFY: dead code 0x0005-0006 in Lorg/ksoap2/transport/ServiceConnectionMidp;.openOutputStream()Ljava/io/OutputStream; 
01-27 09:29:56.135: INFO/dalvikvm(1074): Could not find method javax.microedition.io.HttpConnection.setRequestMethod, referenced from method org.ksoap2.transport.ServiceConnectionMidp.setRequestMethod 
01-27 09:29:56.135: WARN/dalvikvm(1074): VFY: unable to resolve interface method 117: Ljavax/microedition/io/HttpConnection;.setRequestMethod (Ljava/lang/String;)V 
01-27 09:29:56.145: DEBUG/dalvikvm(1074): VFY: replacing opcode 0x72 at 0x0002 
01-27 09:29:56.145: DEBUG/dalvikvm(1074): VFY: dead code 0x0005-0005 in Lorg/ksoap2/transport/ServiceConnectionMidp;.setRequestMethod (Ljava/lang/String;)V 
01-27 09:29:56.165: INFO/dalvikvm(1074): Could not find method javax.microedition.io.HttpConnection.setRequestProperty, referenced from method org.ksoap2.transport.ServiceConnectionMidp.setRequestProperty 
01-27 09:29:56.165: WARN/dalvikvm(1074): VFY: unable to resolve interface method 118: Ljavax/microedition/io/HttpConnection;.setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V 
01-27 09:29:56.165: DEBUG/dalvikvm(1074): VFY: replacing opcode 0x72 at 0x0002 
01-27 09:29:56.175: DEBUG/dalvikvm(1074): VFY: dead code 0x0005-0005 in Lorg/ksoap2/transport/ServiceConnectionMidp;.setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V 
01-27 09:30:05.580: WARN/ActivityManager(106): Launch timeout has expired, giving up wake lock! 
01-27 09:30:05.796: WARN/ActivityManager(106): Activity idle timeout for HistoryRecord{4405ce08 myapp.android.v2/.myPage} 
+1

「崩潰我的應用程序」太模糊。你可以給'adb logcat *:D' – 2011-01-27 05:07:03

回答

1

您需要下載J2SE版本,而不是J2ME版本。

1

當我嘗試調試我的應用程序時也出現了同樣的錯誤。我能夠通過重新鏈接KSOAP2 SE庫而不是使用me版來糾正它。

0

我有同樣的錯誤,我必須清除Java Build Path中除Android#。(其中#。#是您在項目中使用的版本號)以外的所有條目。然後,我清理了這個項目(Project,Clean),並且所有這些似乎都奏效了。

0

原來,這是一個程序員錯誤

我正在調用一個不存在的webmethod。

有沒有方法稱爲MyFunction