Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android web服务响应失败Soap 2_Android_Asp.net_Android Ksoap2 - Fatal编程技术网

Android web服务响应失败Soap 2

Android web服务响应失败Soap 2,android,asp.net,android-ksoap2,Android,Asp.net,Android Ksoap2,我是Android新手,我创建了一个小应用程序并调用了一个web方法。它一直工作正常,但突然停止工作,它无法连接到WS。我正在使用KSOAP2。我可以通过浏览器访问WS。我没有对代码做任何更改,它在交付时工作正常,但停止运行 版本-姜饼,使用Eclipse,WS是asmx。我正在使用带有2.6.5 jar的KOSAP2。请帮助我将其设置为非常关键的,而不是 package bt.Mobile.abc; import org.ksoap2.SoapEnvelope; import org.kso

我是Android新手,我创建了一个小应用程序并调用了一个web方法。它一直工作正常,但突然停止工作,它无法连接到WS。我正在使用KSOAP2。我可以通过浏览器访问WS。我没有对代码做任何更改,它在交付时工作正常,但停止运行

版本-姜饼,使用Eclipse,WS是asmx。我正在使用带有2.6.5 jar的KOSAP2。请帮助我将其设置为非常关键的

,而不是

package bt.Mobile.abc;

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.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

public class HelloAndroidActivity extends Activity {
    private static final String APP_TAG = "BT Android";

    // TO VALIDATE THE LOGIN
    private static final String SOAP_ACTION = "http://SmartApp.boothtracker.com/ValidateLogin";
    private static final String METHOD_NAME = "ValidateLogin";
    private static final String NAMESPACE = "*****.com/";
    private static final String URL = "*****.asmx";

    TextView tvUserName;
    TextView tvPassword;
    TextView tvStatus;
    ProgressBar progressBar1;

    /** SelectedBooth used to store the Selected Booths **/
    public String SelectedBooth;

    public String getSelectedBooth() {
        return SelectedBooth;
    }

    public void setSelectedBooth(String SelectedBooth) {
        this.SelectedBooth = SelectedBooth;
    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {           
        super.onCreate(savedInstanceState);

        new eula.OnEulaAgreedTo() {

            public void onEulaAgreedTo() {
                // TODO Auto-generated method stub

            }
        };

        // VALIDATE USER LOGIN
        try
        {
            setContentView(R.layout.main);

            // INITIALIZE CONTROLS USED IN FORM
            tvUserName=(TextView)findViewById(R.id.editText1);
            tvPassword=(TextView)findViewById(R.id.editText2);
            tvStatus=(TextView)findViewById(R.id.txtStatus);

            progressBar1 = (ProgressBar)findViewById(R.id.progressBar1);
            progressBar1.setVisibility(View.GONE);

            Button b = (Button)findViewById(R.id.btnSignIn);            
            b.setOnClickListener(new View.OnClickListener(){
                public void onClick(View arg0){ 

                    progressBar1.setVisibility(View.VISIBLE);
                    tvStatus.setText("Processing...");

                    try {
                        // INVOKE THE WS TO GET THE LOGIN VALIDATED 
                        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);                       
                        request.addProperty("UserName", tvUserName.getText().toString());`enter code here`
                        request.addProperty("Password", tvPassword.getText().toString());                   
                        Toast.makeText(getApplicationContext(), ("Connecting"), Toast.LENGTH_LONG).show();
                        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);                     
                        envelope.dotNet=true;
                        envelope.setOutputSoapObject(request);
                        Toast.makeText(getApplicationContext(), (URL), Toast.LENGTH_LONG).show();
                        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                        androidHttpTransport.call(SOAP_ACTION, envelope);                   
                        Toast.makeText(getApplicationContext(), ("Sending"), Toast.LENGTH_LONG).show();
                        Object result = (Object)envelope.getResponse();

                        String strResult = result.toString();

                        progressBar1.setVisibility(View.GONE);

                        if  (strResult.equals("True"))
                        {
                            //LOGIN WAS SUCESSFULL - PROCED TO NEXT PAGE
                            tvStatus.setText("Login Successfull, Please Wait...");
                            tvPassword.setText("");
                            Intent i = new Intent(HelloAndroidActivity.this, newfile.class);
                            startActivity(i);
                            finish();
                        }
                        else
                        {
                            // LOGIN FAILED TO AUTHENTICATE
                            Toast.makeText(getApplicationContext(), ("Invalid Username and Password"), Toast.LENGTH_LONG).show();
                            tvStatus.setText("Invalid username & password");
                            tvPassword.setText("");
                        }

                    } catch (Exception e) {
                        // LOGIN FAILED; NOTIFY THE USER AND WAIT
                        Toast.makeText(getApplicationContext(), (e.getMessage()), Toast.LENGTH_LONG).show();
                        tvStatus.setText("Connection Failure");
                        tvStatus.setText(e.getMessage());
                        tvPassword.setText("");
                    }
                }
            });
        }
        catch (Exception e)
        {
            Log.e(APP_TAG, Log.getStackTraceString(e));
        }
    }
}
试用

 Object result = (Object)envelope.getResponse();

Logcat中的任何错误…粘贴一些代码。。。最好能给你一些帮助。我也遇到过同样的问题,它工作了好几次,然后什么也没发生。我得到答复的方式有问题。发布您的代码SOAP\u操作名称是否与运行web服务时获得的URL相同?是否尝试重新启动eclipse?是的..我尝试了。。4天以来我一直在挣扎。。一切都很好。。现在我需要交付,但没有成功:(我也是android新手,没有太多经验。我会在早上把这个问题传递给我的朋友。谢谢Sinu。这将在紧急情况下对我有很大帮助。请等待答复。)
 SoapPrimitive result = (SoapPrimitive) envelope.getResponse();