http://code.google.com/p/ksoap2-android/
解决方案 »
- 安装小白SDK Manager打不开
- GestureDetector.SimpleOnGestureListener中onScroll的参数e2.getX的问题
- android webdav
- android 录制网络视频流
- 统计软件安装次数
- 程序退出时如何保存activity的活动状态
- android解锁事件捕获
- 关于父Activity更新UI
- 如何ping一个域名,返回对应的IP,并得到ip?
- 安卓调用webservice 返回的datatable 和 list 要怎么解析啊
- 关于3.0版本的android.graphics.Canvas.getGL没有了的问题
- 怎样列出/data/data/mypackage/files目录下的文件结构
使用方法如下:public class TestWebService extends Activity {
private static String NameSpace="http://tempuri.org/";
private static String u="http://10.8.8.70:808";//请更换成你要访问的服务器地址
private static String webService="/webService/WebService.asmx";//webService目录
private static String MethodName="HelloWorld2";//要调用的webService方法
private static String soapAction=NameSpace+MethodName;
private static String url=u+webService;
private TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.tv);
tv.setText(ws());
}
//webService操作要访问网络,所以最好是使用线程来做,这里只是示例,所以就不考虑了
private String ws(){
String result="";
try{
SoapObject request=new SoapObject(NameSpace,MethodName);//NameSpace
//webService方法中的参数,这个根据你的webservice来,可以没有。
//但请注意,参数名称和参数类型客户端和服务端一定要一致,否则将可能获取不到你想要的
//request.addProperty("x",5);
//request.addProperty("y", 6);
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE ht=new HttpTransportSE(url);
ht.call(soapAction, envelope);
if(envelope.getResponse()!=null){
SoapPrimitive response=(SoapPrimitive)envelope.getResponse();
result=response.toString();//这里获得了webService的返回值
}
}catch(Exception e){
result=e.getMessage();
}
return result;
}
}
http://code.google.com/p/android-ws-client/downloads/list
可以一起研究一下,我碰到了跟你同样的问题。
谁有兴趣一起研究一下,老外的网址是:
http://code.google.com/p/android-ws-client/