Когда я пытаюсь вызвать веб-сервис для входа в систему, вход не удался

Когда я пытаюсь войти в систему через веб-службу dotnet, она выдает эту ошибку

03-15 17:15:28.899 29517-29959/com.example.welcom.abhinav
I/httpTransportSE: org.ksoap2.transport.HttpTransportSE@76bc3be 03-15
17:15:28.903 29517-29959/com.example.welcom.abhinav
D/NetworkSecurityConfig: No Network Security Config specified, using
platform default 03-15 17:15:29.050
29517-29959/com.example.welcom.abhinav I/messge: false

Это xml-код

<?xml version = "1.0" encoding = "utf-8"?>

<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"

xmlns:app = "http://schemas.android.com/apk/res-auto"
xmlns:tools = "http://schemas.android.com/tools"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical"
tools:context = "com.example.welcom.abhinav.MainActivity">


<EditText
    android:id = "@+id/loc"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:ems = "10"
    android:hint = "Location"
    android:inputType = "textPersonName" />

<EditText
    android:id = "@+id/email"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:ems = "10"
    android:hint = "Email"
    android:inputType = "textPersonName" />

<EditText
    android:id = "@+id/password"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:ems = "10"
    android:hint = "Password"
    android:inputType = "textPassword" />

<Button
    android:id = "@+id/signin"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:text = "Sign In" />

<TextView
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:text = "TextView"
    android:id = "@+id/textView1"/>

<TextView
    android:id = "@+id/textView2"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:text = "TextView" />

<TextView
    android:id = "@+id/textView3"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:text = "TextView" />
 </LinearLayout>

Этот класс, из которого мы можем подключиться к веб-сервису из приложения Android.

package com.example.welcom.abhinav;

import android.util.Log;

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;

/**
* Created by welcom on 15-03-2018.
*/

public class WebService {
    private static String NAMESPACE = "http://tempuri.org/";
    private static String URL  = "http://www.getcodify.in/webservice.asmx";
    private static String SOAP_ACTION = "http://tempuri.org/";

    public static  Boolean invokeHelloWorldWS(String user,String pass, String location,  String webMethName)
    {
        Boolean loginStatus=false;
        SoapObject request = new SoapObject(NAMESPACE, webMethName);

        PropertyInfo userPI=new PropertyInfo();
        PropertyInfo passPI=new PropertyInfo();
        PropertyInfo locationPI=new PropertyInfo();

        userPI.setName("user");
        userPI.setValue(user);
        userPI.setType(String.class);
        Log.i("user",user);
        passPI.setName("pass");
        passPI.setValue(pass);
        passPI.setType(String.class);
        Log.i("pass",pass);
        locationPI.setName("location");
        locationPI.setValue(location);
        locationPI.setType(String.class);
        Log.i("location",location);
        SoapSerializationEnvelope soapSerializationEnvelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapSerializationEnvelope.dotNet=true;
        soapSerializationEnvelope.setOutputSoapObject(request);
        HttpTransportSE httpTransportSE=new HttpTransportSE(URL);
        Log.i("httpTransportSE",httpTransportSE.toString());
        try{
            httpTransportSE.call(SOAP_ACTION+webMethName,soapSerializationEnvelope);
            SoapPrimitive response= (SoapPrimitive) soapSerializationEnvelope.getResponse();
            loginStatus=Boolean.parseBoolean(response.toString());
            Log.i("messge",loginStatus.toString());

        }
        catch (Exception e)
        {
            MainActivity.errored=true;
            e.printStackTrace();

        }
        return loginStatus;
    }
}

это основной класс активности приложения, в котором мы можем вызвать webservice.class

   package com.example.welcom.abhinav;

   import android.content.Intent;
   import android.os.AsyncTask;
   import android.support.v7.app.AppCompatActivity;
   import android.os.Bundle;
   import android.util.Log;
   import android.view.View;
   import android.widget.Button;
   import android.widget.EditText;
   import android.widget.ProgressBar;
   import android.widget.TextView;
   import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Button logIn;
    EditText location;
    EditText emailEt;
    EditText passEt;
    TextView disLoc;
    TextView disEm;
    TextView disPass;
    Boolean displayLocation;
    String displayEmail;
    String displayPassword;
    String loc;
    String em;
    String pass;
    static Boolean errored=false;
    //ProgressBar progressBar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        location=findViewById(R.id.loc);
        emailEt=findViewById(R.id.email);
        passEt=findViewById(R.id.password);
        logIn=findViewById(R.id.signin);

        disLoc=findViewById(R.id.textView1);
        disEm=findViewById(R.id.textView2);
        disPass=findViewById(R.id.textView3);

        logIn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (location.getText().length() != 0 && location.getText().toString() != "" ||
                        emailEt.getText().length() != 0 && emailEt.getText().toString() != ""||
                        passEt.getText().length() != 0 && emailEt.getText().toString() != "") {

                        loc=location.getText().toString();
                        em=emailEt.getText().toString();
                        pass=passEt.getText().toString();

                        AsyncCallWS task=new AsyncCallWS();
                        task.execute();
                }
                else
                {
                    Toast.makeText(getApplicationContext(), "Please fill all fields", Toast.LENGTH_LONG).show();
                }

            }
        });
    }

    private class AsyncCallWS extends AsyncTask<String,Void, Void>
    {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            //progressBar.setVisibility(View.VISIBLE);
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
           //disLoc.setText(displayLocation);


            //progressBar.setVisibility(View.INVISIBLE);

            if (!errored)
            {
                if (displayLocation)
                {
                    Toast.makeText(getApplicationContext(),"Login Succesful", Toast.LENGTH_LONG).show();
                }
                else
                {
                    Toast.makeText(getApplicationContext(),"Login Failed, Try again", Toast.LENGTH_LONG).show();
                }
            }
            else
            {
                Toast.makeText(getApplicationContext(),"Error occured in invoking webservice", Toast.LENGTH_LONG).show();
            }
            errored=false;
        }

        @Override
        protected void onProgressUpdate(Void... values) {
            super.onProgressUpdate(values);
        }

        @Override
        protected Void doInBackground(String... strings) {
            displayLocation=WebService.invokeHelloWorldWS(em, pass, loc,"Login");
            return null;
        }
    }
}
stackoverflow.com/questions/39933345/…
AskNilesh 15.03.2018 12:57

так в чем ошибка

Abhinav Sindhu 15.03.2018 12:58
Пользовательский скаляр GraphQL
Пользовательский скаляр GraphQL
Листовые узлы системы типов GraphQL называются скалярами. Достигнув скалярного типа, невозможно спуститься дальше по иерархии типов. Скалярный тип...
Как вычислять биты и понимать побитовые операторы в Java - объяснение с примерами
Как вычислять биты и понимать побитовые операторы в Java - объяснение с примерами
В компьютерном программировании биты играют важнейшую роль в представлении и манипулировании данными на двоичном уровне. Побитовые операции...
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Приходилось ли вам сталкиваться с требованиями, в которых вас могли попросить поднять тревогу или выдать ошибку, когда метод Java занимает больше...
Полный курс Java для разработчиков веб-сайтов и приложений
Полный курс Java для разработчиков веб-сайтов и приложений
Получите сертификат Java Web и Application Developer, используя наш курс.
0
2
47
1

Ответы 1

Измените используемые URL-адреса с http на https.

не работает....

Abhinav Sindhu 16.03.2018 06:14

Другие вопросы по теме