3

I am using KSOAP2 in my android application, and when I try to perform a particular webservice request, I got this "double ID" exception. Where i'am going wrong ? Please help me.

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(SOAP_ADDRESS);

        SoapPrimitive response = null;
        try {   
          androidHttpTransport.call(SOAP_ACTION, envelope); //<<--- Getting exception here
          response = (SoapPrimitive)envelope.getResponse();

        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getApplicationContext(), e+"", Toast.LENGTH_LONG).show();
        }

StackTrace :

java.lang.RuntimeException: double ID
at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:407)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
 at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
 at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
 at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
 at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:151)
 at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
 at org.ksoap2.transport.Transport.parseResponse(Transport.java:116)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:235)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
at com.menthatech.soap_login_test.SampleSoapTest_LoginActivity.onClick(SampleSoapTest_LoginActivity.java:94)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
sachi
  • 2,122
  • 7
  • 30
  • 46

3 Answers3

1

I had this exception today... I don't know if your case is the same...

In my case was because the Webservice (C#) return a Dataset, but, I work that changing some columns and return then, so, I have 2 Tables with same Id. with diffgr:before tag.

So, when you work your dataset just put the code before your Webservice return the object:

ds.AcceptChanges();

:-)

Lucio Flavio
  • 91
  • 2
  • 3
0

Here is nice example that might help you: Click Here

Here is my quick fix to this issue:

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);

SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
soapEnvelope.setOutputSoapObject(Request);
soapEnvelope.dotNet = true;


List<Integer> companies =  new ArrayList<Integer>();
companies.add(65);
companies.add(66);
companies.add(67);

Request.addProperty("name", "test1");
SoapObject soapCompanies = new SoapObject(NAMESPACE, "companies");
for (Integer i : companies){
    soapCompanies.addProperty("int", i);
}
Request.addSoapObject(soapCompanies);

Output XML:

<n0:companies xmlns:n0 = "http://tempuri.org/">
            <int i:type = "d:int">65</int>
            <int i:type = "d:int">66</int>
            <int i:type = "d:int">67</int>
</n0:companies>
<name i:type = "d:string">test1</name>
Yash
  • 1,751
  • 13
  • 14
-1

I want to record different solutions for people who encounter this problem....

Because call the DataSet data back to XML use the "diffgram". The "double ID" error is <diffgr:id> repeate,have the same ID

e.g:
A Table have "Table"、"Table1" (if your dataSet select more table)
if "A" have 11 records and show to the XML is
<Table diffgr:id="Table1">、<Table diffgr:id="Table2">.........<Table diffgr:id="Table11">

if B have 10 records and show to the XML is
<Table1 diffgr:id="Table11">、<Table diffgr:id="Table12">.........<Table diffgr:id="Table110">

SO. You can see the diffgr:id="Table11" repeat. That is why have "double Id" error

Solution

change the DataSet Table name

SqlDataAdapter.Fill(DataSet);
DataSet.Tables[0].TableName = "Table_";
DataSet.Tables[1].TableName = "Table1_";
DataSet.AcceptChanges();

PuShu
  • 1
  • 1