首页 新闻 会员 周边 捐助

android 调用 .net webservice

0
悬赏园豆:10 [待解决问题]

public class WebServiceTest extends Activity {

  

    private static final String Name_Space = "http://tempuri.org/";

    private static final String Method_Name = "HelloWorld";

    private static final String URL = "http://190.160.10.79:7890/WebService1.asmx";

    private static final String Soap_Action = "http://tempuri.org/HelloWorld";

    private SoapObject rpc = null;

    private HttpTransportSE ht = null;

    private SoapSerializationEnvelope envelope = null;

   @Override

   protected void onCreate(Bundle savedInstanceState) {

      // TODO Auto-generated method stub

      super.onCreate(savedInstanceState);

      this.setContentView(R.layout.webservice_test);

     

      Button btn = (Button)this.findViewById(R.id.myButton);

      btn.setOnClickListener(new Button.OnClickListener(){

 

         @Override

         public void onClick(View v) {

            // TODO Auto-generated method stub

            new Thread(){

                public void run()

                {

                   try

                   {

                        rpc = new SoapObject(Name_Space, Method_Name);

                   }

                   catch(Exception e)

                   {

                      Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();

                   }

                    envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

                   envelope.bodyOut = rpc;

                   envelope.dotNet = true;

                   envelope.setOutputSoapObject(rpc);

                  

                    ht = new HttpTransportSE(URL);

                   ht.debug = true;

                   try

                   {

                      //调用webservice方法

                      ht.call(Soap_Action, envelope); 

                      //返回webservice

                      SoapObject detail = (SoapObject)envelope.getResponse();到这里报错,为什么呢?

                      Toast.makeText(getApplicationContext(), detail.toString(), Toast.LENGTH_LONG).show();

                   }

                   catch (IOException e)

                   {

                      e.printStackTrace();

                   }

                   catch (XmlPullParserException e)

                   {

                      e.printStackTrace();

                   }

                }

            }.start();

         }

        

      });

   }

  

KimhillZhang的主页 KimhillZhang | 菜鸟二级 | 园豆:209
提问于:2013-05-06 18:01
< >
分享
所有回答(1)
0

报什么错?

八戒的师傅 | 园豆:1472 (小虾三级) | 2013-05-07 09:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册