-2

My MainActivity.java

package com.test11;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity

{


private static String SOAP_ACTION1 = "http://tempuri.org/Service/ValidateUser";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME1 = "ValidateUser";
private static String URL = ".....";

Button button1;
EditText editText1,editText2;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    button1 = (Button)findViewById(R.id.button1);


    button1.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
        editText1 = (EditText)findViewById(R.id.editText1);
        editText2 = (EditText)findViewById(R.id.editText2);
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);       

        request.addProperty("parameters",editText2.getText().toString());

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);



        envelope.setOutputSoapObject(request);
        envelope.dotNet = true;

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

        androidHttpTransport.debug = true;


        try {



            androidHttpTransport.call(SOAP_ACTION1, envelope);

            SoapObject result = (SoapObject)envelope.bodyIn;




            if(result != null)
            {

                editText1.setText(result.getProperty(0).toString());
            }
            else
            {

                Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
            }
        } catch (Exception e) 
        {

            e.printStackTrace();
        }
        }


    });    

}




}

I try to make an android app which gives a user name and connect it with a web service so it will return me true or false if the username exists or not. I run this in eclipse using ksoap2 and always returns false...even with existing username.

Cœur
  • 37,241
  • 25
  • 195
  • 267
dimcode
  • 213
  • 3
  • 16

1 Answers1

0

Maybe your problem isn't in your android code, but in the webservice. Try testing it directly in your webservice

  • how can i test it directly??? Please enlighten me cause i dont know much about web services – dimcode Jul 15 '13 at 14:42
  • Do something like http://tempuri.org/Service/ValidateUser?parameters=myusername. Test it in your web browser – Marc-André Therrien Jul 15 '13 at 14:45
  • also i have test this with visual studio and it runs ok...so webservice is 90% correct. Any other ideas?? – dimcode Jul 15 '13 at 14:47
  • Can you post what you received in result? – Marc-André Therrien Jul 15 '13 at 14:49
  • I run it in the emulator of eclipse and it returns me false instead of true which is the return when i run it with the visual studio – dimcode Jul 15 '13 at 14:57
  • Also whatever i put in the place of "parameters" in the request.addProperty methode (ex.request.addProperty("bullshit",editText2.getText().toString());) it returns me false, if that helps you to help me. – dimcode Jul 15 '13 at 15:01