2 alloverjandy AlloverJandy 于 2013.06.07 10:49 提问

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个回答

wang123kui
wang123kui   2013.06.07 11:10

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

   }

}

AlloverJandy
AlloverJandy 不是这个问题也
接近 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!