日期:2014-05-18  浏览次数:20559 次

一个接口文件“IService”
接口文件“IService”:

namespace _11.LINQtoSQL.Web
{
  // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
  [ServiceContract]
  public interface IService1
  {
  [OperationContract]
  List<Product> GetChartData();
  }
}

问题一:“ServiceContract”是什么???他的作用是什么???

问题二:“OperationContract”是什么???他的作用是什么???

------解决方案--------------------
http://xyztony1985.blog.163.com/blog/static/36117820090592128676/
http://topic.csdn.net/u/20110412/13/3137206e-9ad3-4c39-b152-21f9a82d7da6.html
------解决方案--------------------
自定义标签
------解决方案--------------------
这是WCF定义契约时候的标签。
[ServiceContract] 标识的接口会被WCF暴露给外部以供调用。
[OperationContract] 用来标记暴露给外部的方法。
------解决方案--------------------
WCF 包含 WebService,WebService 在.net 4.0已经没有Project Template了。

比如你用 WCF 的 wsHttpBinding, basicHttpBinding 这两种绑定时,其实就是 WebService 了。