概要:
初次接触WCF,结果惨不忍睹。高手飘过,新手的去看TerryLee原版吧一步一步学Silverlight 2系列(14):数据与通信之WCF。
这个就留给我当做以后复习的笔记吧。
WCF:
既然是用WCF通信,那么首先在Web文件里建立WCF-Service,命名为Blog.svc。然后web文件夹就会多出Blog.svc和IBlog.cs。
开头有I的,一般都是接口。IBlog.cs里有个默认的void DoWork();同样在Blog.svc就有个DoWork的实现方法。
例子中就是在接口中声明一个类,返回Post[]类型。在Blog.svc有这个例子的具体方法。
这个还好理解。
然后在web.config中修改:<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SilverlightAppDemo1.Web.BlogBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SilverlightAppDemo1.Web.BlogBehavior"
name="SilverlightAppDemo1.Web.Blog">
<endpoint address="" binding="basicHttpBinding" contract="SilverlightAppDemo1.Web.IBlog">
</endpoint>
</service>
</services>
</system.serviceModel>