【问题标题】:How to call .Net Web Services in Android Application Using Eclipse如何使用 Eclipse 在 Android 应用程序中调用 .Net Web 服务
【发布时间】:2011-08-02 09:12:56
【问题描述】:

Android 应用程序中的新手如何在 Android 中调用 .Net WebServices 正在实现 我的代码是请检查

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
     tv = (TextView)findViewById(R.id.textView1);
    call();
}
public void call()
{
    try {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        request.addProperty("hello", "world");

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet=true;
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug=true;

        androidHttpTransport.call(SOAP_ACTION, envelope);

      // SoapPrimitive sp=(SoapPrimitive)envelope.getResponse();

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

        tv.setText(result.toString());
    }
    catch (Exception e) 
    {
        tv.setText(e.getMessage());

    }
}

但是我缺少错误分隔符,操作超时,请任何人帮助我如何使用 Eclipse 调试 Android 应用程序

谢谢 @Lakshmi

【问题讨论】:

    标签: .net android web-services


    【解决方案1】:

    您不能在 UI 线程上执行任何网络操作,否则您的 Android 将生成 ANR 错误对话框。将您的网络代码放在AsyncTask 中以避免出现 ANR 错误。

    请注意,如果没有看到 logcat 输出,我无法确定这是您遇到的错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-03
      • 2014-11-24
      • 1970-01-01
      相关资源
      最近更新 更多