100分求助 android调用webservice异常org.xmlpull.v1.XmlPullParserException 文件本身也没错误 应该就是写的xml方式有问题,也没有用过你解析的那个类;你先找个简单的能解析xml成功的共用的调用webservice的比较下吧 比如什么天气信息的那种看看别人怎么写的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主 这个和我的代码很像 我也报这个异常,我调用 webservice不带参数的方法和带一个参数的方法 都能得到数据 带两个参数就报这个异常。不知道 怎么回事。哪位达人解决下。 楼主 问题解决了么 我这的问题解决了。下面是我的代码public String GetDataByWeb(String mthod,Object[] params) { soap=new SoapObject(WSNamespace,mthod); if(params.length==1) soap.addProperty("GroupList", params[0]); else { soap.addProperty("Uname",params[0]); soap.addProperty("PassWord", params[1]); } envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut=soap; envelope.dotNet=true; AndroidHttpTransport transport=new AndroidHttpTransport(WSUrl); transport.debug=true; try { transport.call(WSNamespace+mthod, envelope); if(envelope.getResponse()!=null){ SoapObject retValue=(SoapObject) envelope.getResponse(); return retValue.getProperty(0).toString(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return "IOException"; } catch (XmlPullParserException e) { // TODO Auto-generated catch block e.printStackTrace(); return "XmlPullParserException"; } return "error"; }//////个人感觉 参数名称很重要 我收到了数据 还没有做解析 envelope.dotNet=true; 我设置的是true 楼主试试 看对不 在onCreate方法里加上StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() // or .detectAll() for all detectable problems .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .penaltyLog() .penaltyDeath() .build()); 就好了,我也是今天才找到解决的办法的 你把返回结果的方法getResponse 换成getProperty(0),然后在解析返回的数据试下,我记得我用getResponse方法会报错 // 定义Web Service提供服务的URL static final String SERVICE_URL = "http://172.16.1.10/oa/services/UserWebService?wsdl";改成static final String SERVICE_URL = "http://172.16.1.10/oa/services/UserWebService";就可以了 org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='http://webservice.service.oa.org'>@2:523 in java.io.InputStreamReader@4056be18) 看错误就是xml解析的错误而 而且看提示应该时START_TAG 解析开始节点时出的错 你可以把得到的xml文件输出出来 ,看看是不是你要的 遇到同样的问题。把static final String SERVICE_URL = "http://172.16.1.10/oa/services/UserWebService?wsdl";改成static final String SERVICE_URL= "http://172.16.1.10/oa/services/UserWebService";就可以了本人亲自试过 @Test public void allRegion() {// 声明一个webservice客户端 WebserviceClient client = new WebserviceClient("http://www.xxxx.com:8088/apk/webservice", "regionWs", "allRegion", null, List.class, Region.class); List<Region> list = client.execute();// 执行以下webservice客户端,就得到了一个List,轻松搞定 for (Region member : list) { System.out.println(member.getName()); } }我们都是这样调webservice的好像你那代码又长又啰嗦 android 怎么获取画在画布上的大小 请教关于编译skia的问题 android 在线播放视频如何实现?有哪些方式? Android Canvas Bitmap 线程什么时候会用到?怎么实现线程同步? 如何不通过数据库的方式获取一个音频文件的详细信息 请问怎么打开auto monitor logcat提示框 Action如何换掉返回箭头 RadioGroup里面的RadioButton的布局问题 小米8 setRequestedOrientation不起作用 定时器和开机通知都没有效果,在线求助 android编程百度地图
我调用 webservice不带参数的方法和带一个参数的方法 都能得到数据 带两个参数就报这个异常。不知道 怎么回事。哪位达人解决下。
我这的问题解决了。
下面是我的代码
public String GetDataByWeb(String mthod,Object[] params)
{
soap=new SoapObject(WSNamespace,mthod);
if(params.length==1)
soap.addProperty("GroupList", params[0]);
else
{
soap.addProperty("Uname",params[0]);
soap.addProperty("PassWord", params[1]);
}
envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut=soap;
envelope.dotNet=true;
AndroidHttpTransport transport=new AndroidHttpTransport(WSUrl);
transport.debug=true;
try {
transport.call(WSNamespace+mthod, envelope);
if(envelope.getResponse()!=null){
SoapObject retValue=(SoapObject) envelope.getResponse();
return retValue.getProperty(0).toString();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "IOException";
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "XmlPullParserException";
}
return "error";
}//////个人感觉 参数名称很重要 我收到了数据 还没有做解析 envelope.dotNet=true; 我设置的是true
楼主试试 看对不
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build()); 就好了,我也是今天才找到解决的办法的
static final String SERVICE_URL = "http://172.16.1.10/oa/services/UserWebService?wsdl";
改成
static final String SERVICE_URL = "http://172.16.1.10/oa/services/UserWebService";
就可以了
把static final String SERVICE_URL = "http://172.16.1.10/oa/services/UserWebService?wsdl";
改成static final String SERVICE_URL= "http://172.16.1.10/oa/services/UserWebService";
就可以了本人亲自试过
public void allRegion() {
// 声明一个webservice客户端
WebserviceClient client = new WebserviceClient("http://www.xxxx.com:8088/apk/webservice", "regionWs", "allRegion",
null, List.class, Region.class);
List<Region> list = client.execute();// 执行以下webservice客户端,就得到了一个List,轻松搞定
for (Region member : list) {
System.out.println(member.getName());
}
}我们都是这样调webservice的
好像你那代码又长又啰嗦