先得到:
![](/images/smiles/icon_mad.gif)
1.命名空间 nameSpace
2.服务器段的方法名称 methodName
3.写入的服务器WEBServices地址 endPoint
SoapSerializationEnvelope envelope =SoapSerializationEnvelop(SoapEnvelope.VER10);
SoapObject soapObject = new SoapObject(nameSpace, methodName);
envelope.bodyOut = soapObject;
envelope.dotNet = true;
transport = new HttpTransportSE(endPoint);
然后如果直接调用远程服务器方法会报错方法,不能在主线程调用远程服务其方法,所以我写写了一个线程:
@Override
public void run() {
try {
transport.call(soapAction, envelope);
SoapObject object = (SoapObject)envelope.bodyIn;
String result = object.getProperty(0).toString();//传的是json数据,取第一个
JSONObject json = new JSONObject(result);
if (json.getString("results").equals("成功")) {//标志位,成功说明获取成功
telerror = json.getString("reason");
} else {
Toast.makeText(CQJC.this, "获取电话信息失败", Toast.LENGTH_SHORT).show();
telerror = "未知数据..........";
}
} catch (Exception e) {
telerror = "未知数据..........";
e.printStackTrace();
}
}
然后又有个问题出现了Unterminated object at character这个错误是json格式不对,我的错.....ok,搞定