我正在使用以下代码使用 Ksoap2 进行 Web 服务
package com.google.android.myWebService;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpsTransportSE;
//import org.ksoap2.transport.HttpTransport;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class myWebService extends Activity {
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "http://www.webservicex.net/GetWeatherByPlaceName";
private static final String METHOD_NAME = "GetWeatherByPlaceName";
private static final String NAMESPACE = "http://www.webservicex.net";
private static final String URL = "http://www.webservicex.net/WeatherForecast.asmx?WSDL";
private Object resultsRequestSOAP = null;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
TextView tv = new TextView(this);
setContentView(tv);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// SoapObject
request.addProperty("PlaceName", "new york");
//request.addProperty("lastname", "Williams");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
Log.d(null,"Status : set HttpTransport");
HttpsTransportSE androidHttpTransport = new HttpsTransportSE(URL, 443, "", 5000);
try {
Log.d(null,"Status : b4 Call");
androidHttpTransport.call(SOAP_ACTION, envelope);
Log.d(null,"Status : Call done");
resultsRequestSOAP = envelope.getResponse();
Log.d(null,"Status : Response received");
String[] results = (String[]) resultsRequestSOAP;
tv.setText(results[0]);
} catch (Exception aE) {
//aE.printStackTrace();
Log.d(null,"Exception: " + aE);
}
}
}
但它在 logcat 中给出以下输出:
03-29 16:57:50.961: DEBUG/installd(1096): DexInv: --- BEGIN '/data/app/vmdl42687.tmp' ---
03-29 16:57:51.601: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/xmlpull/v1/XmlPullParser;' has an earlier definition; blocking out
03-29 16:57:51.601: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/io/KXmlParser;' has an earlier definition; blocking out
03-29 16:57:51.601: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/xmlpull/v1/XmlSerializer;' has an earlier definition; blocking out
03-29 16:57:51.611: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/io/KXmlSerializer;' has an earlier definition; blocking out
03-29 16:57:51.611: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/kdom/Node;' has an earlier definition; blocking out
03-29 16:57:51.611: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/kdom/Document;' has an earlier definition; blocking out
03-29 16:57:51.611: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/kdom/Element;' has an earlier definition; blocking out
03-29 16:57:51.611: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/wap/Wbxml;' has an earlier definition; blocking out
03-29 16:57:51.621: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/wap/WbxmlParser;' has an earlier definition; blocking out
03-29 16:57:51.621: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/wap/WbxmlSerializer;' has an earlier definition; blocking out
03-29 16:57:51.621: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/wap/syncml/SyncML;' has an earlier definition; blocking out
03-29 16:57:51.621: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/wap/wml/Wml;' has an earlier definition; blocking out
03-29 16:57:51.621: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/kxml2/wap/wv/WV;' has an earlier definition; blocking out
03-29 16:57:51.621: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/xmlpull/v1/XmlPullParserException;' has an earlier definition; blocking out
03-29 16:57:51.631: DEBUG/dalvikvm(6892): DexOpt: 'Lorg/xmlpull/v1/XmlPullParserFactory;' has an earlier definition; blocking out
03-29 16:57:51.751: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
03-29 16:57:51.761: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
03-29 16:57:51.761: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
03-29 16:57:51.771: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
03-29 16:57:51.771: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
03-29 16:57:51.771: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
03-29 16:57:51.771: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
03-29 16:57:51.791: INFO/dalvikvm(6892): DexOpt: not resolving ambiguous class 'Lorg/kxml2/io/KXmlSerializer;'
03-29 16:57:51.801: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlPullParser;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/io/KXmlParser;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlSerializer;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/io/KXmlSerializer;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/kdom/Node;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/kdom/Document;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/kdom/Element;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/wap/Wbxml;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/wap/WbxmlParser;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/wap/WbxmlSerializer;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/wap/syncml/SyncML;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/wap/wml/Wml;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/kxml2/wap/wv/WV;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlPullParserException;': multiple definitions
03-29 16:57:51.811: DEBUG/dalvikvm(6892): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlPullParserFactory;': multiple definitions
03-29 16:57:51.821: DEBUG/dalvikvm(6892): DexOpt: load 60ms, verify 186ms, opt 8ms
03-29 16:57:51.881: DEBUG/installd(1096): DexInv: --- END '/data/app/vmdl42687.tmp' (success) ---
我的代码有什么问题?