android访问webservices
/**
* 手机号段归属地查询(模拟器、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 ,