500 Internal Server Error when calling .NET web service from android in Java


When i'm trying to invoke my web service(in.NET asmx) from Android Java ... I'm getting

this error ->  500 Internal Server Error.

              -> Response{protocol=http/1.1, code=500, message=Internal Server Error, url=http://example.in/webservice/login.asmx}

 

here is my Login Activity..

/*==========================================================================================================================*/


public class Login_page extends AppCompatActivity { 

    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_page);
        phoneNoET  =  (EditText) findViewById(R.id.editText);
        userNameET = (EditText) findViewById(R.id.editText1);
        passWordET = (EditText) findViewById(R.id.editText2);
        
        b = (Button) findViewById(R.id.login);
        b.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) 
         {
            login();
         }
        });

  }

 public void login() {

        Map<String, String> loginMap = new LinkedHashMap<>();
        String phonenumber, Username, Userpassword;

        phonenumber = phoneNoET.getText().toString();
        Username = userNameET.getText().toString();
        Userpassword = passWordET.getText().toString();

        loginMap.put("phonenumber", phonenumber);
        loginMap.put("Username", Username);
        loginMap.put("Userpassword", Userpassword);
        try {
            Services apiService = ApiHandler.getApiService();
            final Call<LoginModel> loginCall = apiService.Login_web(loginMap);
            loginCall.enqueue(new Callback<LoginModel>() 
            {
                @Override
                public void onResponse(Call<LoginModel> call,  Response<LoginModel> response) 
                 { 
                  if (response.isSuccessful()) 
                      {
                        LoginModel loginModel = response.body();
                        if (loginModel != null) {
                        Log.d("Login_web", "response" + loginModel);
                       }

                    }
                }
 
            });
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
/*==========================================================================================================================*/

public class ApiHandler

{
   private static final String DEV_BASE_URL = "http://example.in/webservice/";
   private static final long HTTP_TIMEOUT = TimeUnit.SECONDS.toMillis(600);
   private static Services apiService;
   private static Retrofit.Builder builder = new Retrofit.Builder().baseUrl(DEV_BASE_URL).addConverterFactory(GsonConverterFactory.create());
   private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

public static Services getApiService()

   {
      if (apiService == null)

   {

      HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
      logging.setLevel(HttpLoggingInterceptor.Level.BODY);
      httpClient.addInterceptor(logging);
      Retrofit retrofit = builder.client(httpClient.build()).build();
      apiService = retrofit.create(Services.class);
      return apiService;
   } else

   {
      return apiService;
   }
}
}

/*==========================================================================================================================*/

 

public interface Services {


    @FormUrlEncoded
    @POST("login.asmx")
    Call<LoginModel> Login_web(@FieldMap Map<String, String> map);
}


/*==========================================================================================================================*/

 
public class LoginModel implements Serializable {
    @SerializedName("Bank_ID")
    @Expose
    public String Bank_ID;
    

    public String getBank_ID() {
        return Bank_ID;
    }

    public void setBank_ID(String Bank_ID) {
        this.Bank_ID = Bank_ID;
    }
 
}

/*==========================================================================================================================*/

 


Asked by:- nikhil_bangar
0
: 536 At:- 1/10/2018 9:26:44 AM
Java Internal-server-error-500 web-service-call






1 Answers
profileImage Answered by:- pika

Not a android expert, but you can call .NET .asmx using KSOAP , here are the few links which have explained it very well

http://programmerguru.com/android-tutorial/how-to-call-asp-net-web-service-in-android/  (You can also download demo source code and try to call your .asmx by changing url and class as required.)

https://androidexample.com/Dot_Net_Webservice_Call_-_Android_Example/index.php?view=article_discription&aid=100

https://www.codeproject.com/Articles/304302/Calling-Asp-Net-Webservice-ASMX-From-an-Android-Ap

https://www.journaldev.com/13639/retrofit-android-example-tutorial (Retrofit example which you are using, you can try demo source code of this project also which is provided in the link and execute it locally by changing required url and class)

1
At:- 1/10/2018 11:02:27 AM
Thank you for ur reply maa'm.... i seen that all links but there all related to KSOP .. & KSOP is not comfortable for my project... 0
By : nikhil_bangar - at :- 1/10/2018 11:59:51 AM
last link is related to your project using Retrofit , did you tried that, download the source code and replace it with your web service details 0
By : pika - at :- 1/10/2018 12:28:05 PM
yaa ... i already used Retrofit in my project.. 0
By : nikhil_bangar - at :- 1/10/2018 1:00:42 PM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use