0

I have a Web Service I need to call in Silverlight and I can't figure out how to do it.

Most examples I find aren't 3.0 or are talking about WPF. Any assistance would be appreciated.

EDIT: Made some progress, still can't get it working though. It says it's returning a void but in my service I'm returning a list. (Unless this isn't calling my method. I assumed it added "async" to my method name.)

        FileServiceSoapClient sc = new FileServiceSoapClient();
        List<string> x = sc.GetFilesAsync();
Ber53rker
  • 1,036
  • 3
  • 17
  • 26
  • What have you tried, and why didn't it work? Normally, you just right-click on your Silverlight project in Visual Studio Solution Explorer and select "Add Service Reference". – RobSiklos Jun 06 '12 at 20:30
  • @RobSiklos I can't figure out how to access the web service from the .xaml.cs. – Ber53rker Jun 06 '12 at 20:40

1 Answers1

1

All web service calls need to be non blocking in silverlight. Your FileServiceSoapClient should have completion events that you can wire into which will contain the results of your service calls

For instance something along the lines of

FileServiceSoapClient sc = new FileServiceSoapClient();
sc.GetFilesCompleted += (sender, args) =>
{
     List<string> x = args.Result;
     //do something with "x" here
};
sc.GetFilesAsync();
Kenneth Ito
  • 5,201
  • 2
  • 25
  • 44