Can an XML document have 2 elements with the same id or not?

1k views Asked by At

I'm trying to integrate an Android application with a SOAP webservice using kSoap2. I manage to make a request and get some data back but when response parsing happens, I have the following RuntimeException:

W/System.err: java.lang.RuntimeException: double ID
                  at org.ksoap2.serialization.SoapSerializationEnvelope.resolveReference(SoapSerializationEnvelope.java:462)
                  at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:439)
                  at com.easywsdl.exksoap2.serialization.ExSoapSerializationEnvelope.read(ExSoapSerializationEnvelope.java:86)
                  at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:304)
                  at com.easywsdl.exksoap2.serialization.ExSoapSerializationEnvelope.readUnknown(ExSoapSerializationEnvelope.java:93)
                  at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:434)
                  at com.easywsdl.exksoap2.serialization.ExSoapSerializationEnvelope.read(ExSoapSerializationEnvelope.java:86)
                  at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:304)
                  at com.easywsdl.exksoap2.serialization.ExSoapSerializationEnvelope.readUnknown(ExSoapSerializationEnvelope.java:93)
                  at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:434)
                  at com.easywsdl.exksoap2.serialization.ExSoapSerializationEnvelope.read(ExSoapSerializationEnvelope.java:86)
                  at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:146)
W/System.err:     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
                  at com.easywsdl.exksoap2.mtom.MTOMSoapSerializationEnvelope.parse(MTOMSoapSerializationEnvelope.java:70)
                  at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)
                  at org.ksoap2.transport.HttpTransportSE.parseResponse(HttpTransportSE.java:304)
                  at com.easywsdl.exksoap2.transport.AdvancedHttpsTransportSE.parseResponse(AdvancedHttpsTransportSE.java:35)
                  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:276)
                  at com.easywsdl.exksoap2.transport.AdvancedHttpsTransportSE.call(AdvancedHttpsTransportSE.java:51)
                  at be.brusafe.brusafeplus.xds.iti18.DocumentRegistry_Binding_Soap12.sendRequest(DocumentRegistry_Binding_Soap12.java:102)
                  at be.brusafe.brusafeplus.xds.iti18.DocumentRegistry_Binding_Soap12.execute(DocumentRegistry_Binding_Soap12.java:181)
                  at be.brusafe.brusafeplus.xds.iti18.DocumentRegistry_Binding_Soap12.DocumentRegistry_RegistryStoredQuery(DocumentRegistry_Binding_Soap12.java:147)
                  at be.brusafe.brusafeplus.xds.iti18.DocumentRegistry_Binding_Soap12$2.Func(DocumentRegistry_Binding_Soap12.java:168)
                  at be.brusafe.brusafeplus.xds.iti18.DocumentRegistry_Binding_Soap12$2.Func(DocumentRegistry_Binding_Soap12.java:166)
                  at be.brusafe.brusafeplus.xds.iti18.DocumentRegistry_Binding_Soap12$3.doInBackground(DocumentRegistry_Binding_Soap12.java:218)
                  at be.brusafe.brusafeplus.xds.iti18.DocumentRegistry_Binding_Soap12$3.doInBackground(DocumentRegistry_Binding_Soap12.java:207)
                  at android.os.AsyncTask$2.call(AsyncTask.java:333)
                  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                  at java.lang.Thread.run(Thread.java:764)

And indeed, in the response, I have 2 elements with different types but with the same value for their id attribute.

<ExtrinsicObject home="urn:oid:1.3.6.1.4.1.48336.1" id="urn:uuid:3468543d-5033-4d6b-86a5-f8a52fd0070e"
    isOpaque="false"
    lid="urn:uuid:3468543d-5033-4d6b-86a5-f8a52fd0070e"
    mimeType="text/xml"
    objectType="urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1"
    status="urn:oasis:names:tc:ebxml-regrep:StatusType:Approved">

And:

<ObjectRef home="urn:oid:1.3.6.1.4.1.48336.1"
    id="urn:uuid:3468543d-5033-4d6b-86a5-f8a52fd0070e" />

I don't develop the SOAP webservice myself so I told the developers that I don't understand how that's possible because I thought the XML specification itself said IDs had to be unique. And this is what they answered:

In this case it is possible because the atribbute "id" isn't the data type "ID" but the data type "URN". The atribbute is refering to a unique id in the registry and it isn't an id of the element it self. In this application, we are using ebXML Registry Information Model Version 3.0 as default. You can find more information and examples in the document of oasis: https://docs.oasis-open.org/regrep/v3.0/specs/regrep-rim-3.0-os.pdf

And now I'm confused. So can there be several elements with the same ID in an XML document or not? And if yes, is there a way to configure kSOAP2 to make it ignore that double ID?

1

There are 1 answers

2
Michael Kay On

An XML document with duplicate ID values is well-formed but not valid. An XML parser will read such a document successfully if it is running as a non-validating parser.

I don't know the library you are using to do the parsing so I have no idea whether it is possible to disable validation, or to ignore the validation errors.