Section 1: Consuming a Windows Azure-Hosted WCF Service from SharePoint
Silverlight Web Parts make it easy to interact with WCF services, including those hosted in Windows Azure, from SharePoint.
In this lab, you will:
You must have the following items to complete this lab:
The Windows Azure SDK (included in Windows Azure Tools for Visual Studio) installs a simulation environment on your development machine for testing Azure applications locally before deploying them to the cloud. The simulation environment consists of the development fabric to host web and worker roles, and the development storage which simulates cloud blob, table and queue storage locally.
Development storage uses SQL Server as its underlying storage mechanism, and by default the SDK will attempt to configure it to use SQL Server Express. If you do not have SQL Server Express installed before installing the SDK, or you wish to simply use an existing SQL Server instance to host the development storage database, you must run the dsinit command to select the SQL Server instance where the database will be created.
Please see instructions below for how to run dsinit.
Using dsinit to Configure Development Storage
Estimated time to complete this lab: 20 minutes
Exercise 1: Hosting a WCF Service in Windows Azure
Task 1 – Beginning the Exercise
In this task, you will open the lab solution in Visual Studio 2010.
Task 2 – Implementing and Configuring the WCF Service
In this task, you will implement a service operation on the SalaryService WCF service, and modify the web.config file to configure WCF hosting for the service.
Task 3 – Adding a Cross-Domain Policy File
In this task, you will create a client access policy file to allow Silverlight clients to make cross-domain calls to the WCF service. Any Silverlight-enabled WCF service which must allow Silverlight clients to consume it from outside of the domain where the WCF service is hosted must have this file exposed at the root level of its address.
Task 4 – Publishing the WCF Service to Windows Azure
In this task, you will publish the SalaryService to you Windows Azure account.
Exercise 2: Create a Silverlight Application to Consume the WCF Service
Task 1 – Implementing the Silverlight Application
In this exercise you will create a Silverlight application to invoke the WCF service.
Task 2 – Adding the SalarySLDisplay Silverlight Application to Your SharePoint Site
In this task, you will upload the SalarySLDisplay Silverlight application to SharePoint Portal, and display it in a web part.
Consuming Windows Azure-Hosted WCF services from SharePoint is easily accomplished via a Silverlight application running in a Silverlight Web Part. In fact, from the perspective of SharePoint and Silverlight it is no different from consuming a WCF service which is not hosted in Windows Azure. In this lab, you learned how to create a basic WCF service in a Windows Azure web role. You also learned how to create a cross-domain policy file which enables Silverlight applications to call outside of the site in which they’re deployed, enabling access to cloud services. Finally, you learned how to reference a WCF service in the cloud from a Silverlight application, and display that application in a Silverlight web part in SharePoint.