سؤال

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();
هل كانت مفيدة؟

المحلول

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();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top