Creating a Silverlight 2.0 Application that Consumes a WCF Service - Configuring for Silverlight
(Page 2 of 4 )
The following are the steps to configure the WCF Service to be consumed by the Silverlight 2.0 application. Please understand that the entire following configuration is only for a development environment and the configuration for a production environment might be different.
Change “Service1” to “EmpService” everywhere as follows:
Using Solution Explorer, right click on “IService1.vb” and rename it to “IEmpService.vb.”
The above should replace the existing interface “IService1” to “IEmpService” everywhere in the code. If it does not do it automatically, you have to do it manually yourself.
Using Solution Explorer, right click on “Service1.svc” and rename it to “EmpService.svc.”
Go to the code-behind of the same file and change the class name “Service1” to “EmpService.”
Right click on “EmpService.svc” again and select “Open with.”
Now you have to modify the service file itself. In the “Open with” list, select “Source Code (Text) Editor” and click “OK.”
Modify the existing line so that it matches the following:
<%@ ServiceHost Language="VB" Debug="true" Service="DemoEmpService.EmpService" CodeBehind="EmpService.svc.vb" %>
Modify “Web.Config” as follows:
<connectionStrings>
<add name="cnSample" connectionString="Data Source=.sql2k5;initial catalog=sample;user id=sa;password=eXpress2005"/>
</connectionStrings>
Configure a virtual path (using Project properties) and add ClientAccessPolicy.xml as follows:
Using “Solution Explorer,” right click on “DemoEmpService” project and select “Properties.”
Go to the “Web” tab and in the “Server” section, select “Use Local IIS Web Server.”
Provide “http://localhost/DemoEmpService” as the project URL, check on “Override application root” and click on “Create Virtual Directory” (Fig 04).

Save all.
Make sure that “DemoEmpService” is listed in IIS and configured with “ASP.NET 2.0” runtime.
Make sure that both “Anonymous Authentication” and “Integrated Authentication” are enabled for “DemoEmpService” in IIS.
In your web virtual root (usually c:inetpubwwwroot), create a new file , name it “ClientAccessPolicy.xml” and copy the following code (Fig 05).

Next: Writing Code >>
More Windows Scripting Articles
More By Jagadish Chaterjee