views:

1514

answers:

1

I have a webservice that calls a method that returns a generic list of class BodyPartUrls like so:

public List<BodyPartUrls> getCharacterClassBody(int characterClassID)
{
    var bpulst = new List<BodyPartUrls>();
    var iqcb = ydc.ClassBodies.Where(cb =>  cb.characterClassID == characterClassID);

    foreach (var icb in iqcb)
    {
        var bpu = new BodyPartUrls();
        bpu.bodyPartName = icb.BodyPart.bodyPartName;
        bpu.bodyName = icb.Body.bodyName;
        bpu.puppetID = characterClassID;
        bpulst.Add(bpu);
    }
    return bpulst;
}

BodyPartUrls only consists of string and integer properties, note that ydc is refering to a datacontext. This the code in the webservice :

    [WebMethod]
    public List<BodyPartUrls> getCharacterClassBody(int characterClassID)
    {
       return b.getCharacterClassBody(characterClassID);
    }

Now to call the method in silverlight I utalised the following code :

public void initialiseBodiesSoapClientClient()
{
    string webServiceUrl = pu.GetUrlForResource("Bodies.asmx");
    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
    EndpointAddress endpoint = new EndpointAddress(webServiceUrl);
    bsc = new BodiesRef.BodiesSoapClient(binding, endpoint);
    bsc.getCharacterClassBodyCompleted += new EventHandler<Yambushi.BodiesRef.getCharacterClassBodyCompletedEventArgs>(bsc_getCharacterClassBodyCompleted);
}

The method pu.GetUrlForResource get's the url of where the webservice is hosted, the following is method bsc_getCharacterClassBodyCompleted :

void bsc_getCharacterClassBodyCompleted(object sender, Yambushi.BodiesRef.getCharacterClassBodyCompletedEventArgs e)
{
   bpulist = e.Result;
}

bpulist is a generic list of BodyPartUrls, for some reason e.Result is returning ObservableCollection instead of the generic list. I have similar code to retreive other generic lists that work fine so I really can't understand why this is acting differently.

+3  A: 

Click Configure Service Reference. Under the Data Type section you can select what type you want collections or dictionaries to return as.

markti
Heh didnt even need to paste all that code, cheers
Drahcir