Using a Web Service in Silverlight 3.0 ASP.NET
-
13-06-2021 - |
Frage
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();
Lösung
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();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow