Professional Documents
Culture Documents
Open VS2008
2. Select new website and click WCF service
3.
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
public class EmpService
{
[OperationContract]
public string GetEmployeeName(string empName)
{
return "NEW Emp:" + empName;
}
[OperationContract]
public Employee GetEmployeeDetails(Employee employee)
{
return employee;
}
[DataContract]
public class Employee : INotifyPropertyChanged
{
private int _empNo = 0;
private string _empName = string.Empty;
[DataMember]
public int EmpNo
{
get
{
return (_empNo);
}
set
{
_empNo = value;
OnpropertyChanged("EmpNo");
}
}
[DataMember]
public string EmpName
{
get
{
return _empName;
}
set
{
_empName = value;
OnpropertyChanged("EmpName");
}
}
}
16. after enter deploy project name you can see below screen
17.
18. on web application folder -> right click select add-> folder and give your
published website files
19.
20. now right click on Bin folder and select add-> files Seelct bin folder of your
published wesite.
21.
22. now build your deployment project . you can get setup.exe
23. after setup your EXE . you can call in silverlight like Add service reference
name as “EmpServiceReference” give URL of you service which you host in
IIS .
24. before using WCF serive you have to add Two XML files in
C:\Inetpub\wwwroot
25. I. First one is clientaccesspolicy.xml
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
</cross-domain-policy>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using EmpSilverlight.EmpServiceReference;
namespace EmpSilverlight
{
public partial class MainPage : UserControl
{
Employee employee = new Employee();
public MainPage()
{
InitializeComponent();
this.DataContext = employee;
}