android访问webservice
2014-05-07 21:58
253 查看
new AsyncTask<String, Integer, String>() { @Override protected String doInBackground(String... params) { String namespace = "http://tempuri.org/"; //String namespace = "http://www.jskfhn.org.cn/"; String url = "http://www.jskfhn.org.cn/CallCenterWebService/Interface/AppointmentService.asmx"; //String method = "GetAllHospital"; String method = "Init"; String action = namespace+method; SoapObject soap = new SoapObject(namespace, method); //soap.addProperty(name, value); //设置参数 SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER11); env.bodyOut = soap; env.dotNet = true; //env.setOutputSoapObject(soap); HttpTransportSE trans = new HttpTransportSE(url); trans.debug = true; try { trans.call(action, env); if (env.getResponse() != null) { // 获取服务器响应返回的SOAP消息 SoapObject result = (SoapObject) env.bodyIn; Object detail = result.getProperty(method + "Result"); //SoapObject detail = (SoapObject)env.bodyIn; // 解析服务器响应的SOAP消息 return detail.toString() ; } /* SoapObject object = (SoapObject)env.getResponse(); Log.i("result", object.toString());*/ } catch (HttpResponseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace(); } return null; } /* (non-Javadoc) * @see android.os.AsyncTask#onPostExecute(java.lang.Object) */ @Override protected void onPostExecute(String result) { // TODO Auto-generated method stub System.out.println("返回的结果:"+result); } }.execute(); }
相关文章推荐
- Android访问WebService
- 在Android中访问WebService接口的方法
- 安卓访问webservice出现android.os.NetworkOnMainThreadException异常
- 在Android中访问WebService接口的方法
- Android通过WebService访问服务器
- android怎么访问天气webservice,用网上找的链接都不行啊
- ksoap2-android访问webservice,当网络有代理的情况(cmwap)
- Android访问WebService
- Android 3.0 访问WebService 出现 android.os.NetworkOnMainThreadException异常
- android访问webservice设置timeout
- Android访问webservice
- Android 3.0 访问WebService 出现 android.os.NetworkOnMainThreadException异常
- Android 3.0 访问WebService 出现 android.os.NetworkOnMainThreadException异常
- 在Android中访问WebService接口
- Android访问WebService
- 在Android中调用KSOAP2库访问webservice服务出现的服务端传入参数为null的问题解决
- xfire生成webservice,Android利用ksoap2访问webservice 之 服务器搭建
- android 2.2版本之后,访问WebService 出现 android.os.NetworkOnMainThreadException异常 处理办法
- WebService连接sql serever并使用Android端访问数据
- Android访问调用Webservice