Pryderi's notes
1. Make sure that your web server has MIME types for .xaml (application/xaml+xml) and .xap (application/x-silverlight).
2. In VS create a new project using Other Project Types -> Visual Studio Solutions -> Blank Solution. Call it, say, SilverlightAppCallingWebService.
3. Right click on the solution in solution explorer, click add, new project, Visual C#, Web , ASP.NET Web Service Application. For this example leave the name as WebService1..
4. In the web service project properties click on the web tab and select use IIS Web Server and click create virtual directory. Under startup Action click Specific Page and set to Service1.asmx.
5. Test web service in your browser at http://localhost/WebService1/Service1.asmx
6. Right click on solution, add new project, under Visual C# select silverlight , silverlight application, leave the default name as SilverlightApplication1. Then it should suggest linking to the WebService1 project, so click OK.
7. right click on SilverlightApplication1 project and select add service reference. Click Discover. You should see Service1.asmx. Click ok.
8. In page.xaml between the grid labels add<TextBlock x:Name="txtResult" />9. In page.xaml.cs, change the page class to look like this
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
ServiceReference1.Service1SoapClient proxy = new ServiceReference1.Service1SoapClient();
proxy.HelloWorldCompleted +=
new EventHandler<ServiceReference1.HelloWorldCompletedEventArgs>(proxy_HelloWorldCompleted);
proxy.HelloWorldAsync();
}
void proxy_HelloWorldCompleted(object sender, ServiceReference1.HelloWorldCompletedEventArgs e)
{
txtResult.Text = e.Result;
}
}