Android Ksoap wcf

来源:互联网 发布:枪火兄弟连2 mac 存档 编辑:程序博客网 时间:2024/05/23 12:01
 // 命名空间 String serviceNameSpace = "http://tempuri.org/"; String methodName = "GetAllPersons"; // 请求URLString serviceURL = "http://10.0.3.2:65458/WCFService2/Service.svc"; //private static final String serviceURL = "http://10.14.4.67:3009/ITHmeApp/ITHomeService.asmx"; // SoapAction  String soapAction = "http://tempuri.org/IPersonService/GetAllPersons"; //private static final String soapAction = "http://tempuri.org/ReceviceCommand"; // 指定WebService的命名空间和调用的方法名 SoapObject request = new SoapObject(serviceNameSpace, methodName); // example方法中有一个String的参数,这里将“android client”传递到example request.addProperty("i", "oh"); request.addProperty("a","a1"); request.addProperty("b1","b1"); // 获得序列化的Envelope SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(         SoapEnvelope.VER11); envelope.dotNet = true; envelope.bodyOut = request; // Android传输对象 HttpTransportSE transport = new HttpTransportSE(serviceURL); transport.debug = true; // 调用WebService try {     transport.call(soapAction, envelope); } catch (IOException e) {     Log.d("KSOAP", e.toString()); } catch (XmlPullParserException e) {     Log.d("KSOAP", e.getMessage()); } try {     if (envelope.getResponse() != null) {         Log.d("KSOAP", "go3: "+envelope.getResponse().toString()+envelope.toString());     } } catch (SoapFault e) {     Log.d("KSOAP", "error"); }
0 0
原创粉丝点击