Tuesday, April 20, 2010

Silverlight WCF and Azure

Azure is the cloud server base technology. WCF services can produce server pages which can be consumed by Silverlight. However this operation can be tricky.
I participated in an interesting thread Silverlight 3 / November Azure CTP / WCF Sample topic:

http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/4722b0bc-65eb-4315-8044-9a8c3e715d1c
Allen Chen came up with an interesting sample for this.
http://cid-2fa13ebc6cc8e80f.skydrive.live.com/self.aspx/Public/SLWCFInSameWebRole.zip?sa=558372906
This gives you the fundamentals required to make it work in Visual Studio.
This will come up with 2 web pages. The click me button works. The other 8080 port shows an error. Instead of http://127.0.0.1:8080/ if you browse to http://127.0.0.1:8080/Service1.svc you will see the web service and the http://127.0.0.1:8080/Service1.svc?wsdl will produce the XML output for the service.
Couple of key points which make this work.
Note the clientaccesspolicy.xml file and the web.config files
also the proxy setting in the mainpage.xaml.cs file
proxy = new SilverlightApplication1.ServiceReference1.Service1Client(new BasicHttpBinding(),

new EndpointAddress(string.Format("http://{0}:{1}/Service1.svc", HtmlPage.Document.DocumentUri.Host, "8080")));


You may also run into a bug: "Fixing the Silverlight Design Time in a Windows Azure Cloud Service issue in Visual Studio 2008" showing as an “Object reference not set to an instance of an object" in XAML editor. Jim Nakashima has given a fix in his blog
http://blogs.msdn.com/jnak/archive/2010/03/23/fixing-the-silverlight-design-time-in-a-windows-azure-cloud-service.aspx

1 comment:

  1. Bluehost is one of the best hosting provider with plans for all of your hosting requirments.

    ReplyDelete