android访问webservices
2013-10-29 22:01
253 查看
/**
* 手机号段归属地查询(模拟器、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数据存储与访问
- Android访问WCF服务(使用json实现参数传递)
- android网络访问异常:android.os.NetworkOnMainThreadException
- android实现http中请求访问添加cookie的方法
- 在Ubuntu上为Android系统的Application Frameworks层增加硬件访问服务和测试程序
- Android中使用httpclient访问服务器,需要session功能
- Android permission 访问权限大全
- 在Ubuntu上为Android增加硬件抽象层(HAL)模块访问Linux内核驱动程序
- android webview 访问https页面 SslError 处理
- Android之使用HTTP协议访问网络
- Android开发(13)-- 互联网访问图片,在android客户端显示
- Android06_Android资源访问
- 在Ubuntu为Android硬件抽象层(HAL)模块编写JNI方法提供Java访问硬件服务接口
- phonegap-网络访问与调用android手机硬件设备
- 在Android库中不能使用switch-case语句访问资源ID
- android 访问并显示网页