我开发了一个使用KSOAP2 API下载数据的Android应用程序。它适用于Android 2.2,但它不适用于Android 4.0。这两个版本之间是否有任何配置或任何其他差异?
这是代码......`package nj.example;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class AandroidWebserviceActivity extends Activity {
/** Called when the activity is first created. */
private final String NAMESPACE=here`"http://www.naveenbalani.com/webservices/WassupAndroidService/";
private final String URL = "http://naveenbalani.com/WassupAndroid.asmx";
private final String SOAP_ACTION = "http://www.naveenbalani.com/webservices/WassupAndroidService/todaysMessage";
private final String METHOD_NAME = "todaysMessage";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Create Soap Object
SoapObject object=new SoapObject(NAMESPACE,METHOD_NAME);
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(object);
// System.out.println("sset envelope"+envelope);
HttpTransportSE androidtransportSE= new HttpTransportSE(URL);
//System.out.println("after asign url");
try
{
androidtransportSE.call(SOAP_ACTION,envelope); //problem is here
SoapPrimitive response=(SoapPrimitive)(envelope.getResponse());
Log.i("Response", response.toString());
TextView tv = new TextView(this);
tv.setText(response.toString());
setContentView(tv);
}
catch(Exception e){}
}
}
Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nj.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="@string/app_name" >
<activity
android:name=".AandroidWebserviceActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
提前致谢。
二条