Android调用webService使用HttpTransportSE.call()方法出错,求解!

Mr罗夏 2013-11-07 01:58:22
new Thread(new Runnable() {
@Override
public void run() {
Log.e("call", "222");
String url="http://192.168.1.101:8080/ParametersWebService/services/Service";
String methodName="save";
//协议对象
SoapObject request=new SoapObject("http://service.parameters.com", methodName);
request.addProperty("file",1);
//请求对象
SoapSerializationEnvelope ssoe=new SoapSerializationEnvelope(SoapEnvelope.VER11);
ssoe.bodyOut=request;
//执行对象
HttpTransportSE ht=new HttpTransportSE(url);
try {
ht.call(null, ssoe);
Log.e("response", ssoe.getResponse().toString());
if(ssoe.getResponse()!=null){
final Object object=ssoe.getResponse();
Log.e("test", object.toString());
}else{
Log.e("test", "失败");
}
} catch (Exception e) {
Log.e("erro", "12",e);
e.printStackTrace();
}
}
}).start();



错误信息:SoapFault-Faultcod:'soapenv:Server.userException' faultstring:'org.xml.sax.SAXException:SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.' faultactor:'null' detail:org.kxm12.kdom.Node@423190d8
at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializ ationEnvelope.java:141)

求大神指点,小弟刚接触安卓不久。非常感谢
...全文
616 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
画虎烂 2015-01-23
  • 打赏
  • 举报
回复
设置ssoe.dotNet = false;
caochongru 2015-01-22
  • 打赏
  • 举报
回复
正在使用的可用的方法,可以比较下有啥不同,万一不行也可以直接用。 public static String getWebServiceData(String url, String nameSpace, String methodName, Map<String, String> map) { try { // SoapAtion设定 String SOAP_ACTION = nameSpace + methodName; // 处理参数定义 SoapObject rpc = new SoapObject(nameSpace, methodName); // 处理参数设定 if (map != null) { Set<String> keySet = map.keySet(); for (String s : keySet) { rpc.addProperty(s, map.get(s)); } } // 连接服务器 HttpTransportSE ht = new HttpTransportSE(url); _FakeX509TrustManager.allowAllSSL(); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10); // 传给服务器的参数设定 envelope.bodyOut = rpc; envelope.dotNet = true; // 处理结果保存对象设定 envelope.setOutputSoapObject(rpc); // 服务器处理执行 ht.call(SOAP_ACTION, envelope); // 处理结果取得 String resultStr = envelope.getResponse().toString(); // 处理结果返回 return resultStr; } catch (Exception e) { Log.d("Exception Occureed", e.toString()); return "failed"; } }
溜溜球wtj 2015-01-22
  • 打赏
  • 举报
回复
你试一下把AndroidManifest.xml文件中的: <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="18" /> 删掉

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧