problem in ksoap2 in android
Hi all I am having a little problem using ksoap2.
I used ksoap to communicate with the web service, but it gave me the following error please help friends.. as I am new to Android. The code and exception log cat are below. It gives me that exception on the first line of the try
block in my code.
Please take a look and help
CODE IS...
/***********************************************
/PRIVATE DATA MEMBERS
/***********************************************/
private static EditText userName;
private static EditText password;
private static Button submit;
private static TextView tv;
private final String SOAP_ACTION = "action";
private final String METHOD_NAME = "login";
private final String NAMESPACE = "namspace";
private final String URL = "url";
private Object resultRequestSOAP = null;
/***********************************************
/OVERRIDDEN METHODS
/***********************************************/
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
userName = (EditText) findViewById(R.id.user);
password = (EditText) findViewById(R.id.pass);
tv = (TextView) findViewById(R.id.result);
submit = (Button) findViewById(R.id.su开发者_JS百科bmit);
submit.setOnClickListener(this);
//SoapObject abc = new SoapObject();
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.submit:
System.out.println("At start");
SoapObject userRequest=new SoapObject(NAMESPACE, METHOD_NAME);
String email = userName.getText().toString();
String pass = password.getText().toString();
userRequest.addProperty("email", email); // login-account
userRequest.addProperty("password", pass); // login-password
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("UserLogin", userRequest); // login-account
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try {
Object result=envelope.getResponse();
SoapObject resp=(SoapObject) result;
System.out.println(resp.getProperty("result"));
String[] results = (String[]) resultRequestSOAP;
System.out.println("***********"+results[0]);
tv.setText( results[0]);
} catch (Exception aE) {
System.out.println("in catch");
aE.printStackTrace();
}
System.out.println("M At END");
break;
}
}
ERROR LOG CAT IS..
05-10 16:16:22.861: WARN/System.err(312): java.lang.NullPointerException 05-10 16:16:22.881: WARN/System.err(312): at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:513) 05-10 16:16:22.881: WARN/System.err(312): at org.test.FiNear.myFiNear.onClick(myFiNear.java:82) 05-10 16:16:22.891: WARN/System.err(312): at android.view.View.performClick(View.java:2408) 05-10 16:16:22.891: WARN/System.err(312): at android.view.View$PerformClick.run(View.java:8816) 05-10 16:16:22.903: WARN/System.err(312): at android.os.Handler.handleCallback(Handler.java:587) 05-10 16:16:22.903: WARN/System.err(312): at android.os.Handler.dispatchMessage(Handler.java:92) 05-10 16:16:22.911: WARN/System.err(312): at android.os.Looper.loop(Looper.java:123) 05-10 16:16:22.911: WARN/System.err(312): at android.app.ActivityThread.main(ActivityThread.java:4627) 05-10 16:16:22.921: WARN/System.err(312): at java.lang.reflect.Method.invokeNative(Native Method) 05-10 16:16:22.951: WARN/System.err(312): at java.lang.reflect.Method.invoke(Method.java:521) 05-10 16:16:22.951: WARN/System.err(312): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 05-10 16:16:22.951: WARN/System.err(312): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-10 16:16:22.951: WARN/System.err(312): at dalvik.system.NativeStart.main(Native Method) **
SoapObject userRequest=new SoapObject(NAMESPACE, METHOD_NAME);
String email = userName.getText().toString();
String pass = password.getText().toString();
userRequest.addProperty("email", email); // login-account
userRequest.addProperty("password", pass); // login-password
request.addProperty("UserLogin", userRequest); // login-account
you are making two requests ???? is one or if your and to you need to make two calls
精彩评论