问题如题,我想要的是用.cs编写webservice,然后在android客户端获取服务器数据
刚学安卓,求指教~
参考:
在Android中调用C#写的WebService(附源代码)
http://www.cnblogs.com/kissazi2/p/3406662.html
http://blog.csdn.net/lyq8479/article/details/6428288
http://blog.csdn.net/guochunyang/article/details/6203232
调用c#写的webservice和调用java写的webservice区别不大,主要是参数以及返回值的类型要兼容
用ksoap2-android-assembly-2.5.4-jar-with-dependencies.jar这个
static String doMethodonServer(String methodname, Object[] argObjects) {
HttpTransportSE htse = new HttpTransportSE(wsdlUriString);
htse.debug = true;
// 2.使用SOAP1.1协议创建Envelope对象
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
// 3.创建SoapObject对象,该对象需要传入Web Service的命名空间、方法名
SoapObject request = new SoapObject(nameSpace, methodname);
// 4.设置传给WebService的参数
if (argObjects != null && argObjects.length > 0) {
for (int i = 0; i < argObjects.length; i++) {
request.addProperty("arg" + i, argObjects[i]);
}
}
// 5.将SoapObject设置为Envelope的传出SOAP消息体
envelope.bodyOut = request;
try {
htse.call(null, envelope);
if (envelope.getResponse() != null) {
return envelope.getResponse().toString();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}