AlloverJandy 2013-06-07 02:49 采纳率: 0%
浏览 3974

Android 调用 wsdl ,在ht.call 出现 source not found

调试出现 在 ht.call 出现source not found,实在搞不懂了,麻烦帮看下

android 代码:

import android.os.Bundle;
import android.app.Activity;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import java.io.IOException;
import android.view.View;
import android.widget.Button;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class MainActivity extends Activity {

private Button btnGet;
private TextView textview;
final static String SERVICE_NS="http://services.safe/";
final static String SERVICE_URL="http://jandy-ms-7673:8080/SafeShopServices/UserNamePort";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btnGet=(Button)findViewById(R.id.btnGet);
    textview=(TextView)findViewById(R.id.textview);
    btnGet.setOnClickListener(new GetName());

}


private class GetName implements OnClickListener{
    public void onClick(View v)
    {       
        String methodName="getuserName";

        HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);
        ht.debug=true;
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
          SoapObject soop = new SoapObject(SERVICE_NS,methodName);
          soop.addProperty(null);
        envelope.bodyOut=soop;
        try
        {
            ht.call(null,envelope);
            if(envelope.getResponse()!=null)
            {
                textview.setText("123");
            }
            else
                textview.setText("fuck");
        }


        catch(IOException e)
        {
            e.printStackTrace();
        }
        catch(XmlPullParserException e)
        {
            e.printStackTrace();
        }
    }
}

}

wsdl xml:



xsd:schema

/xsd:schema






























  • 写回答

1条回答

  • 桃花岛黄岛主 2013-06-07 03:10
    关注

    调用webservice的方法需要放在一个异步线程中,解决方案如下
    private class DownloadTask extends AsyncTask {
    protected Drawable doInBackground(String... urls) {
    // 此处方你需要调用的方法
    方法名();
    return null;
    }
    protected void onPostExecute(Drawable result) {

       }
    

    }

    评论

报告相同问题?

悬赏问题

  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号