android部分代码:

public List<String> WebList()
{
List<String> Lists = new ArrayList<String>();
String nameSpace = "http://tempuri.org/";//命名空间
String methodName = "PatientList";//方法
String soapAction = "http://tempuri.org/PatientList";//命名空间/方法
String serviceURL="http://192.168.1.22/androidweb/Service1.asmx"; //自己发布的webservcie的地址


org.ksoap2.transport.HttpTransportSE httpTranstation = new HttpTransportSE(serviceURL);
httpTranstation.debug = true;//是否是调试模式

SoapObject soapObject=new SoapObject(nameSpace,methodName);
soapObject.addProperty("str","123");
soapObject.addProperty("remark",":是中国人");
//soapObject.addProperty("参数", "参数值");调用的方法参数与参数值(根据具体需要可选可不选)
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;//注意:这个属性是对dotnetwebservice协议的支持,如果dotnet的webservice 不指定rpc方式则用true否则要用false
envelope.bodyOut = httpTranstation;
envelope.setOutputSoapObject(soapObject);//envelope.bodyOut=request;

try {
httpTranstation.call(soapAction, envelope);
SoapObject result = (SoapObject)envelope.bodyIn;//服务器返回的对象存在envelope的bodyIn中
//下面对结果进行解析,结构类似json对象
int count=result.getPropertyCount();
for(int index=0;index<count;index++){
Lists.add(result.getProperty(index).toString());
}
} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) { // TODO Auto-generated catch block
e.printStackTrace();
}
return Lists;
}


.net部分代码:


[SoapRpcMethod, WebMethod]//具体方法中也要指定rpc方式
public List<string> PatientList(string str,string remark)
{
List<string> List = new List<string>();
List.Add(str + "王二" + remark);
List.Add(str + "张三" + remark);
List.Add(str + "李四" + remark);
return List;
}

效果:


更多相关文章

  1. 浅谈Java中Collections.sort对List排序的两种方法
  2. mybatisplus的坑 insert标签insert into select无参数问题的解决
  3. Python技巧匿名函数、回调函数和高阶函数
  4. Python list sort方法的具体使用
  5. python list.sort()根据多个关键字排序的方法实现
  6. android上一些方法的区别和用法的注意事项
  7. android实现字体闪烁动画的方法
  8. Android中dispatchDraw分析
  9. Android四大基本组件介绍与生命周期

随机推荐

  1. Socket编程java[简单易懂],附带Android(
  2. gradle clean报错Could not find manifes
  3. app:preDebugAndroidTestBuild
  4. android mapview
  5. 分享一个Android日志记录的工具类
  6. Android(安卓)桌面快捷方式操作
  7. android 应用选择器的使用
  8. Android对话框的几种形式
  9. android 界面属性
  10. Android(安卓)DrawBitmap绘制图像