Forum Discussion

nwang66's avatar
nwang66
Contributor
16 years ago

Access Object Array

Hi, 



    The question is very basic, how to new/create an object array? I am testing a web service. The web service's method GetSiteIDlookupResult() returns a parameter, which is an object, type is SiteIDLookupInParam. The object has one property, which is an object array. Please see the screen shot about web service. The following is my code.   

   var result1 = new SiteIDLookupResult();

   var result1 = WebServices.CSISServeWS.GetSiteIDLookupResult(myPara);

   Log.Message(result1.Message);    

   var siteResult = new ArrayOfSiteIDLookup();

   siteResult = result1.SiteIDLookupList;

   Log.Message(siteResult.TypeName);

   //////////  so far it is good /////////////////

   var siteList = ODT.Classes.NewArray();

   siteList = siteResult.SiteIDLookup;  // this is an array of SiteIDLookup

   //the array - siteList is empty, but not null. No value is pass to siteList...?

   var node = new SiteIDLookup();

   node = siteList.CityName; 



   Appreciate any hints!



Nancy

4 Replies

  • This was resovled by modifying code to:

      

        var result1 = new SiteIDLookupResult();

        var result1 = WebServices.CSISServeWS.GetSiteIDLookupResult(myPara); 

        var cityName = result1.SiteIDLookupList.SiteIDLookup(0).CityName;

        

    A for loop can be used to get city name of all nodes.



    Enjoy!



    Nancy
  • chad's avatar
    chad
    Occasional Contributor
    How wold this be accomplished in vb script?  I thought it would be just as straight forward but it doesn't seem to be.

    This code works:

    xresult = builtin.CreateVariantArray(0,1)


    xresult = webservices.Mysvc.GetEmployeeCountByGroup(SvcType_Application, "ABC",SvcType_Groups, SvcType_Token)



    However when I try to analyze anything with the xresult array it doesn't want to allow it.  For instance the code below produces an error stating "Invalid Argument".  Ultimately what I want to be able to do is brwose through the array and verify the properties of the objects returned.




    log.Message(VarArrayLowBound(xresult, 0))





  • Hi,



    First, you overwrite xresult's value. You create an array in the first line and assign another value in the second line - the value assigned in the first line is lost.



    Second, the 'GetEmployeeCountByGroup' name of the method you call implies that this method returns what its name means - a number of some objects (that is, an integer value), not an array.
  • bmifsud's avatar
    bmifsud
    Occasional Contributor
    Thanks guys ... this helped me with a 3 day tormenting issue!!