kSOAP2 double ID exception

落花浮王杯 提交于 2019-12-18 09:22:01

问题


I am attempting to use kSOAP 2 in my android application, and when I try to perform a particular webservice request, I end up getting thrown a "double ID" exception. I was able to find where this gets thrown in the kSOAP source code, it is in the SoapSerializationEnvelope class method public Object read() Here is an excerpt from that code showing the exception being thrown:

        if (id != null) {
            Object hlp = idMap.get(id);
            if (hlp instanceof FwdRef) {
                FwdRef f = (FwdRef) hlp;
                do {
                    if (f.obj instanceof KvmSerializable)
                        ((KvmSerializable) f.obj).setProperty(f.index, obj);
                    else
                        ((Vector) f.obj).setElementAt(obj, f.index);
                    f = f.next;
                } while (f != null);
            } else if (hlp != null)
                throw new RuntimeException("double ID");
            idMap.put(id, obj);
        }

I'm not at all sure what this exception is about, or how I can fix it. Anyone know what the deal with this exception is?

Thanks

Edit:

It should be noted that I am also using a SOAP webservice connection method in the iOS version of this application, and the same exact request does not have any problems.

New information:

Upon closer inspection, the problem seems to be resulting from the xml response I am getting containing a <diffgr:before> element, which has tables with the same ID as above. I think this is the cause of the problem, the other requests I have performed up to this point do not have that element in them, and do not have the exception. So to add to the question: can I stop the webservice from sending this block in its response, or get kSOAP to ignore it?


回答1:


I was able to resolve this by removing the diffgr:before element the webservice was sending. I did that thanks to this post




回答2:


well, I had the same problem too, but I had no diffgr:before in the xml response (And I can't change the webservice at all). Anyway, the problem was due to some empty values in the response. Using XOM I managed to remove all empty elements and the it worked like charm. This is done by converting the response to string, loading it into nu.xom.Document element, remove the empty elements from the document and revert it back to InputStream for parsing with ksoap2



来源:https://stackoverflow.com/questions/6130028/ksoap2-double-id-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!