Interoperavility Between .NET and Java using XML create by xstream

Apr 10, 2009 at 6:55 PM
What is the best way to accomplish the interoperability between .net and java using xml create by xstream.?

Why the xml create on .net is diferente that the one create on java. ? Who can be this setup in a way that both xml are identical, allowing the exchange of data between .net and java using xstream.


XML on .NET
<IVRXML class="ConsoleApplication1.IVRXML, End2EndIVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
  <TransElements>
    <entry>
      <key class="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">3053</key>
      <value class="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">333333333333</value>
    </entry>
    <entry>
      <key class="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">3052</key>
      <value class="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">2222222222222</value>
    </entry>
    <entry>
      <key class="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">3051</key>
      <value class="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">111111111111</value>
    </entry>
    <entry>
      <key class="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">3050</key>
      <value class="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">000000000000</value>
    </entry>
  </TransElements>
</IVRXML>

XML on JAVA
<IVRXML>
  <TransElements>
    <entry>
      <int>3051</int>
      <string>121212121212</string>
    </entry>
    <entry>
      <int>3050</int>
      <string>121212121212</string>
    </entry>
    <entry>
      <int>3053</int>
      <string>121212121212</string>
    </entry>
    <entry>
      <int>3052</int>
      <string>121212121212</string>
    </entry>
  </TransElements>
</IVRXML>

Example Create an application on .NET and java.

public class ELF
    {

        // hast table for holding information
        private Hashtable TransElements = new Hashtable();

        public void printMap()
        {
            printMap(TransElements);
        }

        public void printMap(Hashtable map)
        {
            Console.Out.WriteLine("Print MAP ");
            IDictionaryEnumerator keys = map.GetEnumerator();
            while (keys.MoveNext())
            {
                Console.Out.WriteLine("*KEY* " + keys.Key + ", *OBJECT* " + keys.Value);
            }
            Console.Out.WriteLine("End Print MAP ");
        }

        public ELF()
        {            
        }

        public ELF (Boolean ini)
        {
            if (ini) init();
        }

        public void init()
        {
            TransElements = new Hashtable();
        }

        public void addElement(int ElementID, ELF value)
        {
            TransElements.Add (ElementID, value);
        }

        public void addElement(int ElementID, String value)
        {
            TransElements.Add (ElementID, value);
        }

        public String getElement(int ElementID)
        {
            return TransElements [ElementID].ToString();
        }

        public Hashtable getTransData()
        {
            return TransElements;
        }

        public void setTransData(Hashtable TransElements)
        {
            this.TransElements = TransElements;
        }       
    }

java class.

public class ELF
{

    // Hash Key for Holding the Data Information
    private HashMap <Integer, Object> TransElements = null;

    public ELF()
    {
    }

    public ELF(boolean init)
    {
        if (init) init();
    }

    public void init ()
    {
        TransElements =  new HashMap<Integer, Object>();
    }

    public void getReport ()
    {
        getReport (TransElements);
    }

    public void getReport (HashMap mapvalue)
    {
//        for (Map.Entry<Integer, Object> me : mapvalue.entrySet())
//        {
//            TraceLog.WriteInfo("TransCodeTable","LoadTransCodeFile",String.format (" %d = %s ",me.getKey(),me.getValue().toString()));
//        }
    }


    public void addElement (int ElementID, ELF value)
    {
        TransElements.put(ElementID, value);
    }

    public void addElement (int ElementID, IVRDetail value)
    {
        TransElements.put(ElementID, value);
    }

    public void addElement (int ElementID, String value)
    {
        TransElements.put(ElementID, value);
    }

    public String getElement (int ElementID)
    {
        return (String) TransElements.get(ElementID);
    }

    public HashMap getTransData()
    {
        return TransElements;
    }

    public void setTransData(HashMap TransElements) {
        this.TransElements = TransElements;
    }

}