Search code examples
javaweb-servicesobjectxml-rpcbugzilla

displaying content of Object of someother class, Acessing webservice object


How do I access a object of some other class through my class?? I tried toString but it can display contents only of its own object not other class objects.

Basically, I am able to access Bugzilla Webservice API through java code(xmlrpc) and in return i get a object of class java.util.HashMap. But i am unable to understand how to access the object returned.

    Object createResult = rpcClient.execute("Bug.search", new Object[]{bugMap});

how do i get bugs information from : "createResult" object.ie, contents of cretaeResult object.According to Bugzilla documentation two items are returned, bugs and faults, both are array of hashes. and i want to access these.


Solution

  • In Case someone else needs this. Object from Bugzilla is first typecasted to a HashMap type. Each Keyset of HashMap itself is an object that contains the array of an object where in each object is again a Hashmap. Quite Complex.

    HashMap bugs = (HashMap)bugzillaObject; 
    for( Object key : bugs.keySet() )
    {
    
        Object value = bugs.get( key );
        Object[] valueArray = (Object[])value;
        for( Object v : valueArray )
        {
    
            HashMap L = (HashMap)v;
            for( Object key1 : L.keySet() )
            System.out.println( "Key " + "= "+key1  + ", value " + "= "+ L.get(key1) );
        }
    }