android访问webservices
2013-10-29 09:36
155 查看
/**
* 手机号段归属地查询(模拟器、HTC 可以)
*
* @param phoneSec 手机号段
*/
public void getRemoteInfo() {
/*String phoneSec ="1860028";
// 命名空间
String nameSpace = "http://WebXml.com.cn/";
// 调用的方法名称
String methodName = "getMobileCodeInfo";
// EndPoint
String endPoint = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
// SOAP Action
String soapAction = "http://WebXml.com.cn/getMobileCodeInfo";*/
String nameSpace = "http://phone.centen.com";
String methodName = "LoginCertification";
String endPoint = "http://192.168.0.94:83/phoneService/services/PhoneWebService";
String soapAction = "http://phone.centen.com/LoginCertification";
// 指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
// 设置需调用WebService接口需要传入的两个参数mobileCode、userId
rpc.addProperty("userId", "系统管理员");
rpc.addProperty("psw", "123");
// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的WebService
envelope.dotNet = false;
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
try {
// 调用WebService
transport.call(soapAction, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
String result = object.getProperty(0).toString();
System.err.println(">>>>>>>>>>>>>"+result);
}
* 手机号段归属地查询(模拟器、HTC 可以)
*
* @param phoneSec 手机号段
*/
public void getRemoteInfo() {
/*String phoneSec ="1860028";
// 命名空间
String nameSpace = "http://WebXml.com.cn/";
// 调用的方法名称
String methodName = "getMobileCodeInfo";
// EndPoint
String endPoint = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
// SOAP Action
String soapAction = "http://WebXml.com.cn/getMobileCodeInfo";*/
String nameSpace = "http://phone.centen.com";
String methodName = "LoginCertification";
String endPoint = "http://192.168.0.94:83/phoneService/services/PhoneWebService";
String soapAction = "http://phone.centen.com/LoginCertification";
// 指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
// 设置需调用WebService接口需要传入的两个参数mobileCode、userId
rpc.addProperty("userId", "系统管理员");
rpc.addProperty("psw", "123");
// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的WebService
envelope.dotNet = false;
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
try {
// 调用WebService
transport.call(soapAction, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
String result = object.getProperty(0).toString();
System.err.println(">>>>>>>>>>>>>"+result);
}
相关文章推荐
- Android 访问https的webservices接口
- android如何访问webservices (wsdl 或 asmx)
- 如通过android程序访问网络,比如webservices程序,需要允许程序访问网络,操作如下
- android访问webservices
- android---HttpGet访问服务器
- Android跨应用访问资源启动Activity
- Android permission 访问权限大全
- Android 网络访问框架 NiceDay 发布
- Android模拟器访问本地IIS冲突问题处理方法
- Android跨进程访问资源
- JS辨别访问浏览器判断是android还是ios系统
- Android 访问权限设置
- Android存储访问及目录
- Android 访问权限Permission详解
- Android http https访问网络及资源
- 在Ubuntu上为Android增加硬件抽象层(HAL)模块访问Linux内核驱动程序(老罗学习笔记3)
- 【Android SDK Manager】拒绝访问导致无法下载更新
- [Android]正确地访问网络资源----Proxy的使用
- Android 网络:使用URL访问网络资源,ImageView,下载到本地
- SpeedPHP(在sae上部署)对于移动(android or ios)的访问支持