开发者

Android KSoap2 Webservice use problem

I am using following code to webservice using Ksoap2

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);
        }
    }
}

but it is giving following output in the 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) ---

What is the problem in my code?


There are a couple of answers to this question already here. The second link might be your answer if ksoap2 is still sensitive to trailing slashes.


That's a .Net webservice, you need to set

envelope.dotNet = true;

before executing the request.


It is not an error but just warning about kxml2 and xmlpull classes verification.

You are imported ksoap2.jar library for your project to make build. But ksoap2.jar library has a kxml2 and xmlpull jars inside. And these jars already included in Android OS. Therefore DexOpt utility cant verify libraries from your apk binary. Dont worry about it. OS just will use its own kxml2 and xmlpull libraries but not yours.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜