简体   繁体   English

webservice + android java上的未知错误

[英]unknown error on webservice + android java

unexpected error when i try to retrieve the data from my webservice 当我尝试从Web服务检索数据时发生意外错误

here is my webservice: 这是我的网络服务: 网络服务

here is my android code, i want the result where msgFrom = 1: 这是我的android代码,我想要msgFrom = 1的结果:

private static final String SOAP_ACTION = "http://tempuri.org/selectDB";
    private static final String METHOD_NAME = "selectDB";
    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String URL = "http://localhost:2998/WebService1.asmx";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        final AlertDialog.Builder alert2 = new AlertDialog.Builder(this);
        alert.setTitle("");
        alert.setMessage("Welcome Back,");

        final EditText input = new EditText(this);
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        input.setHint("key in password to proceed");
        alert.setView(input);

        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          Editable value = input.getText();

          try
          {
          SoapObject Request = new SoapObject (NAMESPACE, METHOD_NAME);
          Request.addProperty("msgFrom", "1");

          SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

          soapEnvelope.dotNet = true;
          soapEnvelope.setOutputSoapObject(Request);

          AndroidHttpTransport aht = new AndroidHttpTransport(URL);

            aht.call(SOAP_ACTION, soapEnvelope);
            SoapObject resultString = (SoapObject) soapEnvelope.getResponse();          

            String addon = "";
            for(int i =0; i<resultString.getPropertyCount(); i++)
            {                            
                SoapObject array = (SoapObject) resultString .getProperty(i);
                addon = (addon + array.getProperty(0).toString());        
            }

            alert2.setMessage(addon.toString());
            alert2.show();         
          }
          catch(Exception e)
          {
              alert2.setMessage(e.getMessage());
            alert2.show();
          }
        }
        });

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            // Canceled.
              android.os.Process.killProcess(android.os.Process.myPid());
              System.exit(1);
          }
        });
    }

besides that, i also added internet permission inside my manifest 除此之外,我还在清单中添加了互联网许可

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

here is the logcat: 这是logcat: 在此处输入图片说明

when i press the OK button, the apps is force close. 当我按“确定”按钮时,应用程序将强制关闭。 not even throw an exception error message. 甚至不会抛出异常错误消息。 what did i missed? 我错过了什么? the sample i used here is 'localhost', but i face the same error too after i uploaded the webservices to my server. 我在这里使用的示例是“ localhost”,但是在将Web服务上传到服务器后,我也面临着同样的错误。

KSoap2 library is not in your APK. KSoap2库不在您的APK中。

If you use Eclipse, right click on your project, select "Java build Path", check ksoap2 jar is in tab "Libraries" and in tab "Order & export", Ksoap2 lib must be present and checked. 如果使用Eclipse,请在项目上单击鼠标右键,选择“ Java构建路径”,检查ksoap2 jar是否在“库”选项卡中以及在“订购和导出”选项卡中,必须存在并检查Ksoap2 lib。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM