android - XmlPullParserException意外的令牌 position:TEXT

  显示原文与译文双语对照的内容

在以下方法中出现错误:


 public ResultUsers[] getContacts(java.lang.String user_id, java.lang.String offset, java.lang.String limit,
 java.lang.String phone_contacts) throws SoapFault {
 SoapObject _client = new SoapObject("urn:UserProfile","GetContacts");
 _client.addProperty("user_id", user_id);
 _client.addProperty("offset", offset);
 _client.addProperty("limit", limit);
 _client.addProperty("phone_contacts", phone_contacts);
 SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
 _envelope.bodyOut = _client;
HttpTransportSE _ht = new HttpTransportSE(Configuration.getWsUrl());//line 378
 try {
 _ht.call("urn:UserProfile#GetContacts", _envelope);
 } catch (IOException e) {
 e.printStackTrace();
 } catch (XmlPullParserException e) {
 e.printStackTrace();
 }
 return ResultUsers.toArray((Vector<SoapObject>) _envelope.getResponse());
}

下面是max1452输出:


org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT 
 Fatal error: Ca...@3:1 in java.io.InputStreamReader@41bab9b0) 
 at org.kxml2.io.KXmlParser.next(KXmlParser.java)
 at org.kxml2.io.KXmlParser.next(KXmlParser.java)
 at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java)
 at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
 at org.ksoap2.transport.Transport.parseResponse(Transport.java:118)
 at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:253)
 at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)
 at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111)
 at com.virtulos.virtulosandroid.soap.userprofile.ServerServicePortType.getContacts(ServerServicePortType.java:375)
 at com.virtulos.virtulosandroid.model.db.service.ContactService.getContactsFromCloud(ContactService.java:79)
 at com.virtulos.virtulosandroid.task.LoadContactsTask.doInBackground(LoadContactsTask.java:58)
 at com.virtulos.virtulosandroid.task.LoadContactsTask.doInBackground(LoadContactsTask.java:1)
 at android.os.AsyncTask$2.call(AsyncTask.java)
 at java.util.concurrent.FutureTask.run(FutureTask.java)
 at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
 at java.lang.Thread.run(Thread.java)
 null
 java.lang.NullPointerException
 at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:521)
 at com.virtulos.virtulosandroid.soap.userprofile.ServerServicePortType.getContacts(ServerServicePortType.java:387)
 at com.virtulos.virtulosandroid.model.db.service.ContactService.getContactsFromCloud(ContactService.java:79)
 at com.virtulos.virtulosandroid.task.LoadContactsTask.doInBackground(LoadContactsTask.java:58)
 at com.virtulos.virtulosandroid.task.LoadContactsTask.doInBackground(LoadContactsTask.java:1)
 at android.os.AsyncTask$2.call(AsyncTask.java)
 at java.util.concurrent.FutureTask.run(FutureTask.java)
 at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
 at java.lang.Thread.run(Thread.java)

我在google上发现的是resonse的开始处有 3个字符,通常是由android中的解析器知道的,这就是原因。 但我不确定如何去除这些字符,如果这就是问题,如果我需要直接返回结果。 任何帮助都会非常感激。

时间: 作者:

是的我找到了

获取 WSDL url示例: http://abc.xyz/ws/User.wsdl

然后查找服务名;它可能位于页面的末尾。

比如:


<wsdl:service name="servicename">
 <wsdl:port name="userport" binding="tns:usrbinding">
 <soap:address
 location="http://abc.xyz/soap/ws/ServerWSDL.php"/>
 </wsdl:port>
</wsdl:service>

位置是你的主 url ;你必须将标题设置为该位置 url 。 全部完成。

注意:不要更改 soapAction URL 。

...