Search Wiki:
This sample creates a simple WCF calculator service and builds a Silverlight client for it. The client is then hosted alonside the service in the Azure fabric.

Here is a quick walkthrough of the steps taken to build this solution:
  1. Create new Web Cloud Service project called Calculator
  2. In the Calculator_WebRole website, add a new WCF Service called Service.svc. The service contains two endpoints defined in the Web.config file.
    1. an endpoint using a cusom binary binding over HTTP - can be used by both .Net and Silverlight clients
    2. a metadata endpoint that both .Net and Silverlight clients can use to generate references to the service
  3. Create a Silverlight client by adding a new Silverlight Application project called SilverlightCalculator. When adding the project you will be asked where to host the Silverlight control, and you should accept the default value of hosting it inside of the Calculator_WebRole website. We want the Silverlight control to be hosted alongside the WCF service in the Azure cloud fabric, and this is the exact configuration being suggested.
  4. Add a Service Reference to the WCF Service in the SilverlightCalculator project and use it to call operations

Demo Client | Demo Service

Here is the final result showing the Silverlight client accessing the service:

Silverlight Result.png


Last edited Sep 21 2009 at 6:44 AM  by Yavor, version 6
Comments
markti wrote  Apr 11 2009 at 3:16 PM  
I get this error message when I download and attempt running this sample.

{System.Net.WebException: The remote server returned an error: NotFound ---> System.Net.WebException: The remote server returned an error: NotFound
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}

markti wrote  Apr 11 2009 at 4:03 PM  
[SOLVED]
If you are running Vista, like I am, You may need to register the WCF MIME types for IIS 7. You can do this be running a command prompt in elevated mode and executing this command:

C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i

djarvis8 wrote  Aug 13 2009 at 3:09 PM  
I am able to get this to work on the local development fabric but I get the same "NotFound" error when it's hosted in the cloud. I'm unable to debug any further. Any suggestions?

djarvis8 wrote  Aug 13 2009 at 3:09 PM  
I do have the proper cross domain policy file in place, and I can indeed browse to the .svc file successfully. The service call just response with the NotFound error.

mashby wrote  Aug 20 2009 at 12:21 AM  
I'm getting the following error: The provided URI scheme 'file' is invalid; expected 'http'.
Parameter name: via

Updating...
Page view tracker