android如何访问webservices (wsdl 或 asmx)
来源:互联网 发布:杠杆率 知乎 编辑:程序博客网 时间:2024/06/06 05:52
下文来自:
http://www.ibm.com/developerworks/webservices/library/ws-android/index.html ----- (主要讲解 wsdl格式的访问)
http://blog.163.com/wkai2009@126/blog/static/120177812201071161820/
---------------------------------------------------------------------------------------------------------
android如何访问webservices
在DevDiv中我提过这个问题,非常感谢各位朋友给我提供的资料。经过整理测试现在我整理出来给大家共享
android通过KSOP2访问asmx和wsdl
1.下载ksoap2-android-assembly-2.4-jar-with-dependencies.jar(138m).并加载到工程libraries中。
2.由于android默认是禁用soket所以在开始之前需要修改AndroidManifest.xml。添加:<uses-permission android:name="android.permission.INTERNET" />
3.导入包:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
3.1wsdl的连接:
SoapObject request = new SoapObject("http://172.16.2.53:8080/j2me_webservice1/services/hello", "getHello");
request.addProperty( "name", "name" );
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
HttpTransportSE ht = new HttpTransportSE("http://172.16.2.53:8080/j2me_webservice1/services/hello?wsdl");
try
{
ht.call(null, envelope);
Object Response = envelope.getResult();
MessageBox(Toast.LENGTH_SHORT,Response.toString());
}
catch(Exception ex)
{
MessageBox(Toast.LENGTH_SHORT,ex.getMessage().toString());
}
3.2 asmx连接
String nameSpace = "http://tempuri.org/";
String serviceURL = "http://172.16.2.40/FullerTon/WebService.asmx";
String methodName = "CheckUer";
String soapAction = "http://tempuri.org/CheckUer";
SoapObject request = new SoapObject(nameSpace, methodName);
request.addProperty("UserNum", "111");
request.addProperty("UserPwd", "");
request.addProperty("PdaNum", "111");
request.addProperty("SyncNum", "5.0");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet=true;
HttpTransportSE ht = new HttpTransportSE(serviceURL);
ht.debug = true;
try {
ht.call(soapAction, envelope);
if (envelope.getResponse() != null) {
return envelope.getResponse().toString();
} else {
return "null";
}
} catch (Exception e) {
e.printStackTrace();
return "err";
}
说明:其中nameSpace,soapAction 。用浏览器打开的你的webservice 中都可以找到
- android如何访问webservices (wsdl 或 asmx)
- android访问webservices
- ASMX的WSDL 中返回对象或接收对象中节点的顺序Order
- 根据Wsdl 开发Webservices
- WebServices/SOAP/WSDL/UDDI
- WebServices简介 SOAP\WSDL
- Android 访问 WSDL 接口复习
- Android 访问https的webservices接口
- Java调用WebService接口 wsdl/asmx
- WebServices:WSDL的结构分析
- WebServices的SOAP和WSDL
- WebServices:WSDL的结构分析
- WebServices:WSDL的结构分析
- WebServices:WSDL的结构分析
- ajax 请求ashx或asmx
- webservice远程通过asmx访问
- 如何通过自定义http协议去访问WebServices.
- android WebServices
- QWidget的使用
- jstl与jsp的版本问题:root cause java.lang.NoClassDefFoundError: javax/el/ELException
- EJB3中SessionBean使用Local及Remote接口的注意事项
- MOSS 2010 localized resources
- 在Arch Linux下安装Chrome的DEB包
- android如何访问webservices (wsdl 或 asmx)
- java定时任务处理
- 新手电子商务SEM专员操作指南
- dentry 与inode的概念
- 适配器模式(Adapter)
- 软件工程 敏捷的酒后问答
- 今天用了 NOPI 感觉还真的很不错呵呵!
- WSDL(Web服务描述语言)详细解析
- 进程与线程的区别?