ksoap2 xmlPullParserException未终止的实体裁判裁判、实体、xmlPullParserException

2023-09-05 03:27:20 作者:遇见你是我最美丽的意外

我有一个用户昨天,他和我的应用程序的问题,所以我开始调试了他,将他送我的电话的记录,他是获得推荐我一个 XmlPullParserError 时,他让调用服务器

I have a user email me yesterday that he is having a problem with my application so i started debugging with him and had him sent me the log of the phone and he is getting a XmlPullParserError when he makes a call to the server

E/Message Exchange::CallWebService(6426): Exception: org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:TEXT �������`I�...@1:18 in java.io.InputStreamReader@406c8808) 05-31 12:33:25.573 
W/System.err(6426): org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:TEXT �������`I�...@1:18 in java.io.InputStreamReader@406c8808) 05-31-12:33:25.573 
W/System.err(6426):     at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)05-31 12:33:25.573 
W/System.err(6426):     at org.kxml2.io.KXmlParser.error(KXmlParser.java:269)05-31-12:33:25.573 
W/System.err(6426):     at org.kxml2.io.KXmlParser.pushEntity(KXmlParser.java:781)05-31 12:33:25.573 
W/System.err(6426):     at org.kxml2.io.KXmlParser.pushText(KXmlParser.java:849)05-31 12:33:25.573 
W/System.err(6426):     at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:354)05-31 12:33:25.573 
W/System.err(6426):     at org.kxml2.io.KXmlParser.next(KXmlParser.java:1378)05-31 12:33:25.573 
W/System.err(6426):     at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1408)05-31 12:33:25.573 
W/System.err(6426):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)05-31 12:33:25.573 
W/System.err(6426):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)05-31 12:33:25.573 
W/System.err(6426):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)05-31 12:33:25.573 
W/System.err(6426):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)05-31 12:33:25.573 
W/System.err(6426):     at ecm2.android.MessageExchange$1.run(MessageExchange.java:96)05-31 12:33:25.573 
W/System.err(6426):     at java.lang.Thread.run(Thread.java:1019)05-31 12:33:27.928 

这是它始终未能在该行

trans.call(SOAP_ACTION, soapEnvelope);

这使得调用服务器,它只是抛出一个错误。我有完全相同的电话此人有和我有他跑我跑的确切的版本,我没有问题调用服务器,但他仍然有一个问题。

that makes the call to the server and it just throws an error. I have the same exact phone this person has and I had him running the exact version I am running, I had not problems calling the server but he still had a problem.

我有他卸载并重新安装好几次,所以我不知道什么会导致这对他的电话,而不是我的吗?

I had him uninstall and reinstall several times so I dont know what would cause this on his phone and not mine?

这是我如何创建XML

this is how i create the XML

private static String CreateCallXML(String sDeviceID, String sEMailAddress, String sVersion) {
    Logging logger = new Logging();
    XmlSerializer serializer = Xml.newSerializer();
    StringWriter writer = new StringWriter();
    try {
        serializer.setOutput(writer);
        serializer.startDocument("UTF-8", true);
        serializer.startTag("", "PostData");
        serializer.startTag("", "RetrieveMsg");
        serializer.attribute("", "ver", sVersion);
        serializer.attribute("", "DevID", sDeviceID);
        serializer.attribute("", "eMailAddress", sEMailAddress);
        logger.append("D", className, "CreateCallXML", "LastIncMsgID:" + Settings.LastIncMsgID);
        logger.append("D", className, "CreateCallXML", "LastDLMsgID: " + Settings.LastDLMsgID);
        serializer.attribute("", "LastIncMsgID", "" + Settings.LastIncMsgID);
        serializer.attribute("", "LastDLMsgID", "" + Settings.LastDLMsgID);
        serializer.endTag("", "RetrieveMsg");
        serializer.endTag("", "PostData");
        serializer.endDocument();
        return writer.toString();
    } catch (Exception e) {
        return null;
    }
}

更新2:

在经历了code看来,用户的电子邮件地址是此问题的用户的电子邮件地址的一个例子是在 abcd3961@gmail.com 如果我使用它抛出异常,当它击中线路拨打电话到服务器。如果我更改邮件地址一个字母它执行调用就好了。

after going through the code it appears that the users email address is the problem an example of the users email address is abcd3961@gmail.com if I use that it throws the exception when it hits the line to make the call to the server. If I change one letter in the email address it executes the call fine.

这是一个KSOAP问题?我怎样才能解决这个问题呢,我不能告诉他改变他的电子邮件地址?

is this a ksoap problem? and how can I get around this as i cannot tell him to change his email address?

推荐答案

未终止的实体发生此错误时

1 ...响应字符串错误可能会有些实体不是封闭的。

1... Error in response string may be some entity are not closed.

<root>
    <a> first </a>
    <b>second             <----- </b> missing here
</roor>

2。你得到了一些XML字符在XML文件

2... You are getting some xml character in xml file

 like      & { } � ...

您需要替换所有的&安培; 是&放大器;安培; 看到这个答案

you need to replace all & with & amp; see this answer

...
String str = writer.toString();
str = str.replaceAll("&","&amp;");
str = str.replaceAll("?","&#63;");
return str;