我想调用一个Web服务,但我有一个例外
logcat的
09-15 09:00:08.600: E/AndroidRuntime(1398): FATAL EXCEPTION: main
09-15 09:00:08.600: E/AndroidRuntime(1398): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
09-15 09:00:08.600: E/AndroidRuntime(1398): at net.simonvt.menudrawer.samples.WebserviceCall.getFahrenheit(WebserviceCall.java:38)
09-15 09:00:08.600: E/AndroidRuntime(1398): at net.simonvt.menudrawer.samples.DotNetWebService$1.onClick(DotNetWebService.java:46)
09-15 09:00:08.600: E/AndroidRuntime(1398): at android.view.View.performClick(View.java:4202)
09-15 09:00:08.600: E/AndroidRuntime(1398): at android.view.View$PerformClick.run(View.java:17340)
09-15 09:00:08.600: E/AndroidRuntime(1398): at android.os.Handler.handleCallback(Handler.java:725)
09-15 09:00:08.600: E/AndroidRuntime(1398): at android.os.Handler.dispatchMessage(Handler.java:92)
09-15 09:00:08.600: E/AndroidRuntime(1398): at android.os.Looper.loop(Looper.java:137)
09-15 09:00:08.600: E/AndroidRuntime(1398): at android.app.ActivityThread.main(ActivityThread.java:5039)
09-15 09:00:08.600: E/AndroidRuntime(1398): at java.lang.reflect.Method.invokeNative(Native Method)
09-15 09:00:08.600: E/AndroidRuntime(1398): at java.lang.reflect.Method.invoke(Method.java:511)
09-15 09:00:08.600: E/AndroidRuntime(1398): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-15 09:00:08.600: E/AndroidRuntime(1398): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-15 09:00:08.600: E/AndroidRuntime(1398): at dalvik.system.NativeStart.main(Native Method)
mainactivity.java
public class DotNetWebService extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dot_net_web_service);
final Button webserviceCallButton = (Button) findViewById(R.id.webservice);
final EditText webserviceResponse = (EditText) findViewById(R.id.webserviceResponse);
WebserviceCall com = new WebserviceCall();
//Call Webservice class method and pass values and get response
String aResponse = com.getFahrenheit("Place");
}}
WebserviceCall.java
public class WebserviceCall {
/**
* Variable Decleration................
*
*/
String namespace = "http://tempuri.org";
private String url = "my webservice";
String SOAP_ACTION="http://tempuri.org/Place";
WebserviceCall() {
}
/**
* Set Envelope
*/
public String getFahrenheit(String method) {
String fahren = "erorr";
SoapObject request = new SoapObject(namespace, method);
//Set Name
//Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
//Set output SOAP object
envelope.setOutputSoapObject(request);
//Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
try {
//Invole web service
androidHttpTransport.call(SOAP_ACTION, envelope);
//Get the response
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
//Assign it to fahren static variable
fahren = response.toString();
} catch (Exception e) {
fahren=e.toString();
}
return fahren;
}
/************************************/
}