views:

122

answers:

1

A call from a Silverlight 2.0 control to a WebService, returned via MyWebServiceNameEventArgs is not returning contained List<> aggregates. For Example, I've got a Person class that has a List and List. When I trace the call I see that the person has the lists are populated appropriately. However, when it arrives via the MyWebServiceNameEventArgs the lists are null. the simple types like FirstName, DOB etc are correctly returned.

Is there something I have to do to get the enclosed aggregates to be returned?

Here's my code:

private void btnGetPerson_Click(object sender, RoutedEventArgs e)
{
  var proxy = new TutorWCFServicesClient();
  proxy.GetPersonWithPersonKeyOfCompleted += new EventHandler<GetPersonWithPersonKeyOfCompletedEventArgs>(proxy_GetPersonWithPersonKeyOfCompleted);
  var perID = 29; // testing
  proxy.GetPersonWithPersonKeyOfAsync(perID);
}

void proxy_GetPersonWithPersonKeyOfCompleted(object sender, GetPersonWithPersonKeyOfCompletedEventArgs e)
{
  var per = e.Result;
  if (per != null)
  {
    FirstName.Text = per.FirstName;
    LastName.Text = per.LastName;
    if (per.Phones != null)
    {
      var hPhone = (from phone in per.Phones where phone.PhoneType.ToLower() == "home" select phone).FirstOrDefault();
      var cPhone = (from phone in per.Phones where phone.PhoneType.ToLower() == "cell" select phone).FirstOrDefault();
      var wPhone = (from phone in per.Phones where phone.PhoneType.ToLower() == "work" select phone).FirstOrDefault();

      if (hPhone != null)
      {
        PhoneHome.Text = string.Format("({0}) {1}-{2}", hPhone.AreaCode, hPhone.Exchange, hPhone.Number);
      }
      if (cPhone != null)
      {
        PhoneCell.Text = string.Format("({0}) {1}-{2}", cPhone.AreaCode, cPhone.Exchange, cPhone.Number);
      }
      if (wPhone != null)
      {
        PhoneSchool.Text = string.Format("({0}) {1}-{2}", wPhone.AreaCode, wPhone.Exchange, wPhone.Number);
      }
    }
  }
  else
  {
    FirstName.Text = "Not Found";
  }
}
+1  A: 

Dumb error, I forgot to refresh the ServiceReference in the Silverlight app.

I've been there, believe me :-) and I've slammed my head on my desk trying to figure out what went wrong. +1.
unforgiven3