查看原图(大图)
同时,还会修改web.config文件如下
查看原图(大图)
【注意】这些属于是WCF最基本的知识,如果你对此不清楚,可以参考我有关其他的文章,例如你可以在我的博客中搜索WCF关键字
http://www.google.com.hk/custom?domains=cnblogs.com&q=site:www.cnblogs.com/chenxizhang/+wcf&sitesearch=cnblogs.com&client=pub-4210569241504288&forid=1&channel=5875741252&ie=UTF-8&oe=UTF-8&safe=active&cof=GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:129;L:http://images.cnblogs.com/logo_small.gif;S:http://www.cnblogs.com/;FORID:1&hl=zh-CN
4. 修改该服务,使其具有一个方法,可以获取员工列表
首先修改服务契约
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text;
namespace SilverlightApplication6.Web { // NOTE: You can use the \ command on the \ menu to change the interface name \ in both code and config file together. [ServiceContract] public interface IEmployeeService { [OperationContract] void DoWork();
[OperationContract] Employee[] GetEmployees();
}
[DataContract] public class Employee { [DataMember] public string FirstName { get; set; } [DataMember] public string LastName { get; set; } } } 然后修改服务定义
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text;
namespace SilverlightApplication6.Web { // NOTE: You can use the \ command on the \ menu to change the class name \ in code, svc and config file together. public class EmployeeService : IEmployeeService { public void DoWork() { }
public Employee[] GetEmployees() { return new Employee[]{ new Employee(){FirstName=\ };
} } } 【注意】目前我们只是做演示,还没有读取SharePoint
5. 测试该服务,选中svc文件,然后右键,在浏览器中查看