<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>WCF Tools中国研发团队的博客</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/feed.xml</link>
    <description>我们的目标 -- 开发最好的工具服务于最酷的技术</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:28:58 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>微软技术大会TechEd2010: WCF研发团队的主题演讲和动手实验室</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/teched2010-wcf</link>
      <pubDate>Thu, 16 Dec 2010 18:57:00 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2010/12/16/teched2010-wcf/</guid>
      <description><![CDATA[&nbsp;
今年Tech.Ed北京的主题是云计算（Windows Azure）和Windows Phone...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>今年Tech.Ed北京的主题是<a href="https://www.microsoft.com/en-us/cloud/default.aspx">云计算</a>（Windows Azure）和<a href="https://www.microsoft.com/windowsphone/en-us/default.aspx">Windows Phone 7</a>。相信这不仅体现了微软下一阶段的战略，同时也是业界的主流方向。</p>
<p>WCF团队的演讲也和这个主题密切相关。大家知道WCF在统一编程框架下实现了对五种服务类型的支持：WCF Core Service, WCF Workflow Service, WCF HTTP Service, WCF RIA Service和WCF Data Service。它们分别服务于不同的应用场景，满足服务开发各方面的需求。其中，WCF HTTP服务在云端＋终端的背景下，特别是对mashup聚合服务的需求，以及对多样的终端设备与服务互联互通的应用场景，大有用武之地。</p>
<p>所以我们这次的演讲的主题就是使用WCF开发REST服务，向大家展示WCF HTTP服务的过去，现在和未来，希望这个技术能够为大家所了解，同时也能切实有效地帮助到大家的工作。</p>
<p>下面是简单的介绍，同时也提供了演讲稿的下载供大家参考。</p>
<p><a href="https://www.teched.com.cn/2010/customer/y/SessionView_pop.asp?SessionID=DEV-LANG-300-4"><strong>使用WCF开发REST服务 ── 在Windows Server AppFabric 上，在云端</strong></a></p>
<ul>
<li>简单介绍REST以及其与HTTP的关系，以及REST服务的应用场景； </li>
<li>WCF HTTP服务的初体验，包括如何开发以及在企业内部环境和云端的部署；</li>
<li>WCF 4中对REST服务支持的增强，包括简化的配置、更好的缓存、更灵活的格式选择等；</li>
<li>隆重推出<a href="https://wcf.codeplex.com">https://wcf.codeplex.com</a>，这是WCF REST服务向一等公民演进的开始，能够更灵活的选择格式，以及实现对HTTP消息头的控制等等；</li>
<li>对下一代WCF的展望。</li>
</ul>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/32/28/deck/7774.DEV-LANG-300-4_9B854F654F658765CC51.pptx" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-32-28-deck/7774.DEV_2D00_LANG_2D00_300_2D00_4_5F009B854F654F658765CC51_.pptx">课程讲义下载</a></p>
<p>这里还要提一下<a href="https://wcf.codeplex.com">https://wcf.codeplex.com</a>，WCF CodePlex是WCF研发团队和社区的一个新的沟通渠道。我们会在上面定期发布最新的技术和想法，同时也非常欢迎大家能和我们分享经验和建议，帮助我们构建更加面向用户的技术。</p>
<p>除了演讲，我们团队还有一个动手实验室，在本次技术大会上获得了参会者非常高的评价。在这里我也将简介和指导文档附上，大家有兴趣的也可以动手尝试一下。</p>
<p><strong>Web 服务开发管理新体验 -- WCF4 + Windows Server AppFabric</strong></p>
<p>在本实验中，您先会便捷地创建一个无配置的的Web服务，然后通过Windows Server AppFabric在IIS中集成的全新功能来管理服务。我们将带您管窥WCF和AppFabric的强大功能。</p>
<p>指导文档见附件。</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/10/62/79/ASI03-HOL-CHS.docx" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-10-62-79/ASI03_2D00_HOL_2D00_CHS.docx">ASI03-HOL-CHS.docx</a></p>]]></content:encoded>
    </item>
    <item>
      <title>WCF 4.0中的新特性：简化的配置</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/wcf-4-0</link>
      <pubDate>Fri, 04 Jun 2010 00:41:48 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2010/06/04/wcf-4-0/</guid>
      <description><![CDATA[微软服务器与开发工具事业部 熊炜    自从WCF 问世以来， WCF服务的配置一直是广大开发人员所关心的话题。由于WCF作为一个通用服务框架，拥有大量的拓展点，您有时会觉得配置文件过于复杂。在WCF...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal">微软服务器与开发工具事业部 熊炜</p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN"></span></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">自从</span>WCF <span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">问世以来，</span> WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务的配置一直是广大开发人员所关心的话题。由于</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">作为一个通用服务框架，拥有大量的拓展点，您有时会觉得配置文件过于复杂。在</span>WCF 4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，根据各方面收集的用户反馈，</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">团队对</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">的配置做了大量的简化工作，以方便您更快更好的配置</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务。下面会给大家主要介绍以下几点：</span> </p>  <p></p>  <p></p>  <ul>   <li>     <div style="text-indent: -0.25in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpFirst"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">缺省服务配置</span>         <p></p>     </div>   </li>    <li>     <div style="text-indent: -0.25in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpMiddle"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">标准终结点</span>(Standard Endpoint)         <p></p>     </div>   </li>    <li>     <div style="text-indent: -0.25in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpLast"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">简化的</span>IIS/ASP.NET<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中的部署</span></div>   </li> </ul>  <p style="text-indent: -0.25in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpLast"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN"></span></p>  <h1 style="text-indent: -0.25in; margin-left: 0.25in; mso-list: l1 level1 lfo2"><span style="mso-fareast-font-family: cambria; mso-fareast-theme-font: major-latin; mso-bidi-font-family: cambria; mso-bidi-theme-font: major-latin"><span style="mso-list: ignore">1.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">缺省服务配置</span>     <p></p> </h1>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">我们都知道，在</span>WCF3.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">或</span>3.5<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，对每一个服务我们都必须要详细地定义地址，绑定</span>(binding)<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">，契约</span>(contract)<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">，行为</span>(behavior)<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">等一系列的配置，缺一不可。而在</span>WCF4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，配置文件中增加了许多缺省选项：从终结点，到绑定，各种行为，都可以被省略。下面是一个简单的</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务，运行这个服务甚至不需要配置文件：</span> </p>  <p></p>  <p></p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #d9d9d9; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217">   <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">namespace</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> ConsoleApplication1 </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">class</span> <span style="color: #2b91af">Program</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">static</span> <span style="color: blue">void</span> Main(<span style="color: blue">string</span>[] args) </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;</span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">using</span> (<span style="color: #2b91af">ServiceHost</span> host = <span style="color: blue">new</span> <span style="color: #2b91af">ServiceHost</span>(<span style="color: blue">typeof</span>(<span style="color: #2b91af">Service1</span>), </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">new</span> <span style="color: #2b91af">Uri</span>(<span style="color: #a31515">&quot;https://localhost/Service1&quot;</span>))) </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>host.Open(); </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">ServiceEndpoint</span> endpoint = host.Description.Endpoints[0]; </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;Address: {0}\nBinding: {1}&quot;</span>, endpoint.Address, endpoint.Binding); </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">Console</span>.ReadLine(); </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>} </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"></span>      <p>&#160;</p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>[<span style="color: #2b91af">ServiceContract</span>] </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">class</span> <span style="color: #2b91af">Service1</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>[<span style="color: #2b91af">OperationContract</span>] </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">public</span> <span style="color: blue">void</span> DoWork() </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>} </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">} </span>      <p></p>   </p>    <p></p> </div>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: nsimsun; font-size: 9.5pt; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: nsimsun"></span>    <p>&#160;</p> </p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">运行这个程序结果如下所示：</span> </p>  <p></p>  <p></p>  <p class="MsoNormal"><span style="mso-no-proof: yes"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/17/61/metablogapi/7713.clip_image001_0F209F68.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-17-61-metablogapi/7713.clip_5F00_image001_5F00_0F209F68.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001" border="0" alt="clip_image001" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/17/61/metablogapi/8880.clip_image001_thumb_44D5E4C2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-17-61-metablogapi/8880.clip_5F00_image001_5F00_thumb_5F00_44D5E4C2.png" width="478" height="121" v:shapes="Picture_x0020_1" /></a></span> </p>  <p></p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">可以看到，虽然我们在程序中并没有添加终结点，也没有指定绑定，但</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">还是智能地为我们做了这两项配置，那</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">是通过怎样的机制来做这项设定的呢？</span> </p>  <p></p>  <p></p>  <h2 style="text-indent: -0.25in; margin-left: 45pt; mso-list: l1 level2 lfo2"><span style="mso-fareast-font-family: cambria; mso-fareast-theme-font: major-latin; mso-bidi-font-family: cambria; mso-bidi-theme-font: major-latin"><span style="mso-list: ignore">1.1.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span><span style="mso-spacerun: yes">&#160;</span><span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">缺省的终结点和绑定</span>     <p></p> </h2>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">事实上，</span>WCF4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">框架会自动检测当前将要运行的服务的终结点个数。根据用户反馈，不少程序员会忘记往当前服务中添加终结点，结果自然是在服务运行的时候跳出错误。在</span>4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，如果您指定了服务类型和服务的基本地址，</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">会用这个地址为您自动添加一个终结点。</span> </p>  <p></p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">我们同时可以看到，</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">为这个服务自动选定了</span>BasicHttpBinding<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">。是的，</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">会根据当前</span>URI<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">地址的前缀（在这里是</span>https://<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">），自动挑选对应的缺省绑定。下面是几个常见前缀的默认绑定表：</span> </p>  <p></p>  <p></p>  <table style="border-bottom: medium none; border-left: medium none; border-collapse: collapse; border-top: medium none; border-right: medium none; mso-border-alt: solid #9bbb59 1.0pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-themecolor: accent3; mso-yfti-tbllook: 1184" class="MsoTableLightListAccent3" border="1" cellspacing="0" cellpadding="0"><tbody>     <tr style="mso-yfti-irow: -1; mso-yfti-firstrow: yes">       <td style="border-bottom: medium none; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; background: #9bbb59; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-background-themecolor: accent3; mso-border-top-themecolor: accent3; mso-border-left-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 5" class="MsoNormal"><b><span style="font-family: simsun; color: white; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin; mso-themecolor: background1" lang="ZH-CN">前缀</span><span style="color: white; mso-themecolor: background1"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; background: #9bbb59; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-background-themecolor: accent3; mso-border-top-themecolor: accent3; mso-border-right-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 1" class="MsoNormal"><b><span style="font-family: simsun; color: white; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin; mso-themecolor: background1" lang="ZH-CN">绑定</span><span style="color: white; mso-themecolor: background1"> </span>              <p></p>           </b></p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 0">       <td style="border-bottom: #9bbb59 1pt solid; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-border-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 68" class="MsoNormal"><b>Http </b>            <p></p>         </p>          <p></p>       </td>        <td style="border-bottom: #9bbb59 1pt solid; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 64" class="MsoNormal">BasicHttpBinding </p>          <p></p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 1">       <td style="border-bottom: medium none; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-left-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 4" class="MsoNormal"><b>Net.tcp </b>            <p></p>         </p>          <p></p>       </td>        <td style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-top: medium none; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-right-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal">NetTcpBinding </p>          <p></p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 2; mso-yfti-lastrow: yes">       <td style="border-bottom: #9bbb59 1pt solid; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-border-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 68" class="MsoNormal"><b>Net.Pipe </b>            <p></p>         </p>          <p></p>       </td>        <td style="border-bottom: #9bbb59 1pt solid; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-themecolor: accent3" valign="top" width="319">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 64" class="MsoNormal">NetNamedPipeBinding </p>          <p></p>          <p></p>       </td>     </tr>   </tbody></table>  <p class="MsoNormal"></p>  <p>&#160;</p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">值得注意的是，如果您为您的服务添加了两个不同的基本地址，</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">会为这两个地址分别添加一个终结点。如果这两个终结点地址的前缀不同的话，您就会自动拥有了两个不同绑定的终结点。</span> </p>  <p></p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">如果您希望改动这里的缺省绑定对应，比如，希望用</span>WsHttpBinding<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">来作为</span>Http<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">前缀的缺省绑定，您只需要在配置文件中添加如下语句：</span> </p>  <p></p>  <p></p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #d9d9d9; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217">   <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">system.serviceModel</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">protocolMapping</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">add</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span><span style="color: red; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">scheme</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">=</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;</span><span style="color: blue; font-size: 16pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">http</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;<span style="color: blue"> </span><span style="color: red">binding</span><span style="color: blue">=</span>&quot;</span><span style="color: blue; font-size: 16pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">wsHttpBinding</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;<span style="color: blue">/&gt;</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">protocolMapping</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">system.serviceModel</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt; </span>      <p></p>   </p>    <p></p> </div>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">如果您熟悉</span>WCF ABC (Address<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">，</span>Binding<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">，</span>Contract)<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">话一定会还有一个小疑问：那这边的契约是怎么定义的呢？相信大家一定能够想到，如果当前服务实现了多个</span>WCF <span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务接口，</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">会为每一个接口创建一个新的终结点。这边这些终结点会共用一个服务地址和绑定。由于彼此契约不同，这样的行为并不会引起任何冲突。</span> </p>  <p></p>  <p></p>  <h2 style="text-indent: -0.25in; margin-left: 45pt; mso-list: l1 level2 lfo2"><span style="mso-fareast-font-family: cambria; mso-fareast-theme-font: major-latin; mso-bidi-font-family: cambria; mso-bidi-theme-font: major-latin"><span style="mso-list: ignore">1.2.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">默认的绑定</span>/<span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">行为设定</span>     <p></p> </h2>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">在</span>WCF3.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">或</span>3.5<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，您需要为您的每一个绑定或者行为取一个名字，然后您的每个终结点需要指定某个定义好的绑定或行为来进行应用。可以想象，当您有几十个甚至几百个服务同时应用相同的绑定或行为的时候，指定这些名字将成为单纯的体力劳动。为了避免这样的情况，</span>WCF4.0 <span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">引入了默认绑定</span>/<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">行为的设定。下面是一个默认绑定的例子：</span> </p>  <p></p>  <p></p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #d9d9d9; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217">   <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">system.serviceModel</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">bindings</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">wsHttpBinding</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="background: yellow; color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-highlight: yellow">binding</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">security</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span><span style="color: red; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">mode</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> =</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;<span style="color: blue">Message</span>&quot;<span style="color: blue">&gt;</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">message</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span><span style="color: red; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">clientCredentialType</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">=</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;<span style="color: blue">UserName</span>&quot;<span style="color: blue">/&gt;</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">security</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">binding</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">wsHttpBinding</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">bindings</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">system.serviceModel</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p> </div>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: nsimsun; font-size: 9.5pt; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: nsimsun"></span>    <p>&#160;</p> </p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">请注意这边我们在定义绑定的时候并没有给这个绑定取名字！在</span>WCF 3.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">或</span>3.5<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">版本中是不合法的，但在</span>4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，这样的行为表示默认设定。也就是说在当前配置文件中其他用到</span>WsHttpBinding<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">的服务，如果没有指定对应的绑定，那么就会自动采用这个默认绑定，即拥有采用用户名密码认证模式的消息级安全设定。这样的设定方式无疑能够大大的简化程序员的工作量。</span> </p>  <p></p>  <p></p>  <p class="MsoNormal">WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">的默认行为设定和默认绑定设定的方式类似。同样，如果您在定义完您的服务级行为或者终结点级行为后不特别取一个名字，那么这个行为就能够直接为您所有没指定行为的服务或终结点所采用。</span></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN"></span></p>  <p></p>  <p></p>  <h1 style="text-indent: -0.25in; margin-left: 0.25in; mso-list: l1 level1 lfo2"><span style="mso-fareast-font-family: cambria; mso-fareast-theme-font: major-latin; mso-bidi-font-family: cambria; mso-bidi-theme-font: major-latin"><span style="mso-list: ignore">2.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">标准终结点</span>     <p></p> </h1>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">在</span>WCF 3.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">或</span>3.5<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，为了能够暴露一个元数据端口</span>(metadata endpoint)<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">，您也许常常需要采用如下的方式定义端口：</span> </p>  <p></p>  <p></p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #d9d9d9; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217">   <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">endpoint</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span><span style="color: red; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">address</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">=</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;<span style="color: blue">mex</span>&quot;<span style="color: blue"> </span><span style="color: red">binding</span><span style="color: blue">=</span>&quot;<span style="color: blue">mexHttpBinding</span>&quot;<span style="color: blue"> </span><span style="color: red">contract</span><span style="color: blue">=</span>&quot;<span style="color: blue">IMetadataExchange</span>&quot;<span style="color: blue">/&gt; </span>        <p></p>     </span></p>    <p></p> </div>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">您会发现对于每个服务，元数据端口的设置其实基本上都是一致的，每次重复写同样的设定其实是没有必要的。因此在</span>WCF 4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中，我们将一些常用的终结点规范化，引入了一个“标准终结点”的概念。下面就是一个元数据端口的标准终结点的用法：</span> </p>  <p></p>  <p></p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #d9d9d9; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217">   <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">endpoint</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span><span style="color: red; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">address</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">=</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;<span style="color: blue">mex</span>&quot;<span style="color: blue"> </span><span style="color: red">kind</span><span style="color: blue">=</span>&quot;<span style="color: blue">mexEndpoint</span>&quot;<span style="color: blue">/&gt; </span>        <p></p>     </span></p>    <p></p> </div>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">这里用新关键词“</span>kind<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">”直接指定了这个标准终结点的类型。可以看到这样的写法会为您省下不少工作，同时也减少了出错的可能。另外，和普通的终结点一样，您始终可以在配置文件中对标准终结点的各项设定做出您自己的修改。</span> </p>  <p></p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">下面是</span>WCF4.0 <span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中设定的标准终结点的列表，供您参考：</span> </p>  <p></p>  <p></p>  <table style="border-bottom: medium none; border-left: medium none; border-collapse: collapse; border-top: medium none; border-right: medium none; mso-border-alt: solid #9bbb59 1.0pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-themecolor: accent3; mso-yfti-tbllook: 1184" class="MsoTableLightListAccent3" border="1" cellspacing="0" cellpadding="0"><tbody>     <tr style="mso-yfti-irow: -1; mso-yfti-firstrow: yes">       <td style="border-bottom: medium none; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; background: #9bbb59; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-background-themecolor: accent3; mso-border-top-themecolor: accent3; mso-border-left-themecolor: accent3" valign="top">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 5" class="MsoNormal"><b><span style="font-family: simsun; color: white; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin; mso-themecolor: background1" lang="ZH-CN">标准终结点的名字</span><span style="color: white; mso-themecolor: background1"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; background: #9bbb59; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-background-themecolor: accent3; mso-border-top-themecolor: accent3; mso-border-right-themecolor: accent3" valign="top">         <p style="line-height: normal; margin-bottom: 0pt; mso-yfti-cnfc: 1" class="MsoNormal"><b><span style="font-family: simsun; color: white; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin; mso-themecolor: background1" lang="ZH-CN">描述</span><span style="color: white; mso-themecolor: background1"> </span>              <p></p>           </b></p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 0">       <td style="border-bottom: #9bbb59 1pt solid; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 68; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">mexEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: #9bbb59 1pt solid; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 64; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">元数据终结点。采用</span><span style="color: black">IMetadataExchange </span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">作为服务接口，</span><span style="color: black">mexHttpBinding </span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">作为默认绑定。地址设定默认为空。</span><span style="line-height: 140%; color: black; font-size: 12pt"> </span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 1">       <td style="border-bottom: medium none; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-left-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 4; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">dynamicEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-right-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="color: black">WCF 4.0</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中新引入的支持服务地址动态寻找的</span><span style="color: black">(WS-Discovery)</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">客户端标准终结点。这个标准终结点不需要指定服务地址。当这个终结点第一次被调用时，它会自动根据当前指定的绑定和契约寻找符合要求的服务，并自动返回结果。</span><span style="color: black" lang="ZH-CN"> </span><span style="line-height: 140%; color: black; font-size: 12pt"></span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 2">       <td style="border-bottom: #9bbb59 1pt solid; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 68; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">discoveryEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: #9bbb59 1pt solid; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 64; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="color: black">WCF 4.0</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中新引入的支持</span><span style="color: black">WS-Discovery</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">的服务端标准终结点。使用这个终结点时用户需要指定绑定和契约。</span><span style="color: black" lang="ZH-CN"> </span><span style="line-height: 140%; color: black; font-size: 12pt"></span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 3">       <td style="border-bottom: medium none; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-left-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 4; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">udpDiscoveryEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-right-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="color: black">WCF 4.0</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中新引入的支持</span><span style="color: black">WS-Discovery</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">的服务端标准终结点。它主要支持基于</span><span style="color: black">UDP</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">的服务发现机制。</span><span style="line-height: 140%; color: black; font-size: 12pt"> </span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 4">       <td style="border-bottom: #9bbb59 1pt solid; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 68; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">announcementEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: #9bbb59 1pt solid; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 64; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="color: black">WCF 4.0</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中为了实现</span><span style="color: black">WS-Discovery</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">标准中服务宣告功能而新引入的服务端标准终结点。</span><span style="color: black" lang="ZH-CN"> </span><span style="line-height: 140%; color: black; font-size: 12pt"></span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 5">       <td style="border-bottom: medium none; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-left-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 4; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">udpAnnouncementEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-right-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="color: black">WCF 4.0</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中为了实现</span><span style="color: black">WS-Discovery</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">标准中服务宣告功能而新引入的服务端标准终结点。它主要支持基于</span><span style="color: black">UDP</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">的服务发现机制。</span><span style="line-height: 140%; color: black; font-size: 12pt"> </span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 6">       <td style="border-bottom: #9bbb59 1pt solid; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 68; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">workflowControlEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: #9bbb59 1pt solid; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 64; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">为了工作流进程控制而设计的标准终结点，支持创建，运行，挂起，终结工作流等操作。</span><span style="line-height: 140%; color: black; font-size: 12pt"> </span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 7">       <td style="border-bottom: medium none; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-left-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 4; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">webHttpEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: medium none; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-right-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">为了</span><span style="color: black">REST</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务而设计的标准终结点。它默认采用</span><span style="color: black">WebHttpBinding</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">和</span><span style="color: black">WebHttpBehavior</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">。</span><span style="line-height: 140%; color: black; font-size: 12pt"> </span>            <p></p>         </p>          <p></p>       </td>     </tr>      <tr style="mso-yfti-irow: 8; mso-yfti-lastrow: yes">       <td style="border-bottom: #9bbb59 1pt solid; border-left: #9bbb59 1pt solid; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: medium none; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 68; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><b><span style="color: black">webScriptEndpoint</span></b><b><span style="line-height: 140%; color: black; font-size: 12pt"> </span>              <p></p>           </b></p>          <p></p>       </td>        <td style="border-bottom: #9bbb59 1pt solid; border-left: medium none; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; border-top: #9bbb59 1pt solid; border-right: #9bbb59 1pt solid; padding-top: 0in; mso-border-themecolor: accent3" valign="top">         <p style="line-height: 140%; margin-left: 0.75pt; margin-right: 0.75pt; mso-yfti-cnfc: 64; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class="MsoNormal"><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">为了</span><span style="color: black">Ajax</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务而设计的标准终结点。它默认采用</span><span style="color: black">WebHttpBinding</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">和</span><span style="color: black">WebScriptEnablingBehavior</span><span style="font-family: simsun; color: black; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">。</span><span style="line-height: 140%; color: black; font-size: 12pt"> </span>            <p></p>         </p>          <p></p>       </td>     </tr>   </tbody></table>  <p class="MsoNormal"></p>  <p>&#160;</p>  <p></p>  <h1 style="text-indent: -0.25in; margin-left: 0.25in; mso-list: l1 level1 lfo2"><span style="mso-fareast-font-family: cambria; mso-fareast-theme-font: major-latin; mso-bidi-font-family: cambria; mso-bidi-theme-font: major-latin"><span style="mso-list: ignore">3.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">简化的</span>IIS/ASP.NET<span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">中的部署</span>     <p></p> </h1>  <p class="MsoNormal">WCF 4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">针对用户在</span>IIS<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中的部署做了很多简化工作。如果您曾经在</span>WCF 3.5<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中为</span>ASP.NET<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">项目添加一个</span>WCF<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务，那么先想象一下那时候您需要做的所有操作，然后看一下下面的添加一个</span>WCF 4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">服务的例子：</span> </p>  <p></p>  <p></p>  <p class="MsoNormal">Service1.svc: </p>  <p></p>  <p></p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #d9d9d9; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217">   <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="background: yellow; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; mso-highlight: yellow">&lt;%</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">@</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> <span style="color: maroon">ServiceHost</span> <span style="color: red">Language</span><span style="color: blue">=&quot;C#&quot;</span> <span style="color: red">Debug</span><span style="color: blue">=&quot;true&quot;</span> <span style="color: red">Service</span><span style="color: blue">=&quot;WcfService1.Service1&quot;</span> <span style="background: yellow; mso-highlight: yellow">%&gt;</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"></span>      <p>&#160;</p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">namespace</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> WcfService1 </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">using</span> System.ServiceModel; </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>[<span style="color: #2b91af">ServiceContract</span>] </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">Service1</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>[<span style="color: #2b91af">OperationContract</span>] </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">public</span> <span style="color: blue">void</span> DoWork() </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>} </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">} </span>      <p></p>   </p>    <p></p> </div>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">如果您自己创建了一个</span>ASP.NET<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">项目并且添加了上述服务文件，您会发现：</span> </p>  <p></p>  <p></p>  <p style="text-indent: -0.25in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpFirst"><span style="mso-ascii-font-family: calibri; mso-fareast-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"><span style="mso-list: ignore">-<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">您不再需要单独创建一个接口作为服务的契约了。</span> </p>  <p></p>  <p></p>  <p style="text-indent: -0.25in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpMiddle"><span style="mso-ascii-font-family: calibri; mso-fareast-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"><span style="mso-list: ignore">-<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">您可以直接把您的服务内容写在</span>.svc<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">文件里面，这样可以直接省下一个</span>.svc.cs(<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">或</span>.vb)<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">文件。</span> </p>  <p></p>  <p></p>  <p style="text-indent: -0.25in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpLast"><span style="mso-ascii-font-family: calibri; mso-fareast-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"><span style="mso-list: ignore">-<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">您甚至不需要改动</span>Web.Config<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">就能够使得这个服务自动运行。如果您的</span>Web.Config<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中添加了支持元数据的默认行为，您的服务不需要任何额外设置就拥有了元数据服务支持。</span> </p>  <p></p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">如果您不喜欢用</span>.svc<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">文件而倾向于用</span>.cs<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">或者</span>.vb<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">文件来描述您的服务，您可以反其道而行之，在您的</span>Web.Config<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">文件中添加如下描述：</span> </p>  <p></p>  <p></p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #d9d9d9; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217">   <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">system.serviceModel</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">serviceHostingEnvironment</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">serviceActivations</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">add</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span><span style="color: red; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">relativeAddress</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">=</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&quot;<span style="color: blue">Service1.svc</span>&quot;<span style="color: blue"> </span><span style="color: red">service</span><span style="color: blue">=</span>&quot;<span style="color: blue">WcfService1.Service1</span>&quot;<span style="color: blue">/&gt;</span> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">serviceActivations</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">serviceHostingEnvironment</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt;</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span>      <p></p>   </p>    <p></p>    <p style="border-bottom: medium none; border-left: medium none; padding-bottom: 0in; line-height: normal; padding-left: 0in; padding-right: 0in; margin-bottom: 0pt; background: #d9d9d9; border-top: medium none; border-right: medium none; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt" class="MsoNormal"><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-spacerun: yes">&#160; </span>&lt;/</span><span style="color: #a31515; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">system.serviceModel</span><span style="color: blue; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">&gt; </span>      <p></p>   </p>    <p></p> </div>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">您可以在这一段中添加所有您的服务描述，在舍弃您所有冗余的</span>.svc<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">文件的同时，也使得您的所有服务有了一个统一的描述地点，管理起来更加方便，可谓一举两得。</span> </p>  <p></p>  <p></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">是的，一切就那么简单！</span></p>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN"></span></p>  <p></p>  <p></p>  <h1 style="text-indent: -0.25in; margin-left: 0.25in; mso-list: l1 level1 lfo2"><span style="mso-fareast-font-family: cambria; mso-fareast-theme-font: major-latin; mso-bidi-font-family: cambria; mso-bidi-theme-font: major-latin"><span style="mso-list: ignore">4.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160; </span></span></span><span style="font-family: simsun; mso-ascii-font-family: cambria; mso-ascii-theme-font: major-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: cambria; mso-hansi-theme-font: major-latin" lang="ZH-CN">小结</span>     <p></p> </h1>  <p class="MsoNormal"><span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">以上为大家简单介绍了一下</span>WCF 4.0<span style="font-family: simsun; mso-ascii-font-family: calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: simsun; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: calibri; mso-hansi-theme-font: minor-latin" lang="ZH-CN">中关于简化的配置的新特性。希望这些工作能够为您节省更多的时间，做出更好的产品。也希望能够得到您更多关于我们产品的反馈，以便于我们在下一个版本中做出更多的改进和优化。谢谢！</span></p>]]></content:encoded>
    </item>
    <item>
      <title>使用WCF创建REST服务: 微软2009 MVP Day的演讲稿和示例程序代码</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/wcfrest-2009-mvp-day</link>
      <pubDate>Mon, 11 Jan 2010 05:25:00 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2010/01/11/wcfrest-2009-mvp-day/</guid>
      <description><![CDATA[12月10日，我们在北京微软MVP技术大会上作了一个主题为“使用WCF创建REST服务”的讲座，这个讲座获得了在场MVP的欢迎和热烈讨论，很多MVP在讲座后对讲座上演示使用的例子很感兴趣。在这里我们将...]]></description>
      <content:encoded><![CDATA[<P><FONT size=3 face=宋体>12月10日，我们在北京微软MVP技术大会上作了一个主题为“使用WCF创建REST服务”的讲座，这个讲座获得了在场MVP的欢迎和热烈讨论，很多MVP在讲座后对讲座上演示使用的例子很感兴趣。在这里我们将讲座所用的演示文稿和例子附上。这个例子实现了一个简单的微博服务，在服务端采用WCF REST，在客户端使用Silverlight技术。请用Visual Studio 2010 Beta2打开解决方案文件。</FONT></P>
<P><FONT size=3 face=宋体></FONT></P>
<P><FONT size=3 face=宋体>课程简介请参照之前的课程预告博文：<A title=https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/11/27/mvp-day-wcf-rest.aspx href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/11/27/mvp-day-wcf-rest.aspx" mce_href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/11/27/mvp-day-wcf-rest.aspx">https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/11/27/mvp-day-wcf-rest.aspx</A></FONT></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/94/65/03/DeckAndSample.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-94-65-03/DeckAndSample.zip">DeckAndSample.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>启用WCF测试客户端（WCF Test Client）的相关技巧</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/wcfwcf-test-client</link>
      <pubDate>Sun, 03 Jan 2010 23:33:03 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2010/01/03/wcfwcf-test-client/</guid>
      <description><![CDATA[微软服务器与开发工具事业部 薛在岳      &#160;  &#160;&#160;&#160; WCF测试客户端（WCF Test...]]></description>
      <content:encoded><![CDATA[<p align="right"><font size="2" face="宋体">微软服务器与开发工具事业部 薛在岳</font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p>&#160;</p>  <p><font size="2" face="宋体">&#160;&#160;&#160; </font><a href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/01/12/vs2008-wcf.aspx"><font size="2" face="宋体">WCF测试客户端</font></a><font size="2" face="宋体">（WCF Test Client）是一个用来测试WCF服务程序的调试工具，能够使开发WCF服务更加方便。 本文主要讨论如何在Visual Studio中启用WCF测试客户端的相关技巧。</font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 在Visual Studio之外打开WCF测试客户端有两种方法：第一种方法是到其所在路径（Visual Studio安装路径\Common7\IDE\WcfTestClient.exe）双击打开。第二种方法是在“Visual Studio命令提示（Visual Studio Command Prompt）”中输入“WcfTestClient”命令，如图1所示: </font></p>  <p align="center"><b><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/CMD_2.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/CMD_2.jpg"><font size="2" face="宋体"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="CMD" border="0" alt="CMD" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/CMD_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/CMD_thumb.jpg" width="649" height="453" /></font></a><font size="2" face="宋体"> </font></b></p>  <p align="center"><b><font size="2" face="宋体">图1</font></b></p>  <p align="center"><strong><font size="2" face="宋体"></font></strong></p>  <p><b><font size="2" face="宋体"></font></b></p>  <div><font size="2" face="宋体"></font></div>  <div><font size="2" face="宋体">&#160;&#160;&#160; Visual Studio不同的项目模板，提供了不同的WCF测试客户端启动方法。下面这张表格是Visual Studio 2010 Beta2中，与WCF相关的项目模板： </font></div>  <div><font size="2" face="宋体"></font></div>  <div>&#160;</div>  <div><font size="2" face="宋体"></font></div>  <div><font size="2" face="宋体"></font></div>  <div><font size="2" face="宋体"></font></div>  <div><font size="2" face="宋体"></font></div>  <div align="center">   <table border="1" cellspacing="0" cellpadding="0" width="500" align="center"><tbody>       <tr>         <td width="171">           <p><b><font size="2" face="宋体">项目模板名称</font></b></p>         </td>          <td width="160">           <p><b><font size="2" face="宋体">模板位置</font></b></p>         </td>          <td width="167">           <p><font size="2"><font face="宋体"><b>.NET Framework</b><b>版本</b></font></font></p>         </td>       </tr>        <tr>         <td width="171">           <p><font color="#008000"><font size="2"><font face="宋体"><b>WCF</b><b>服务库</b></font></font></font></p>         </td>          <td width="160">           <p><font size="2" face="宋体">新建项目 -&gt; WCF结点</font></p>         </td>          <td width="167">           <p><font size="2" face="宋体">3.0/3.5/4.0</font></p>         </td>       </tr>        <tr>         <td width="171">           <p><font color="#0080ff"><font size="2"><font face="宋体"><b>WCF</b><b>服务应用程序</b></font></font></font></p>         </td>          <td width="160">           <p><font size="2" face="宋体">新建项目 -&gt; Web结点</font></p>         </td>          <td width="167">           <p><font size="2" face="宋体">3.0/3.5/4.0</font></p>         </td>       </tr>        <tr>         <td width="171">           <p><font color="#0080ff"><font size="2"><font face="宋体"><b>WCF</b><b>工作流服务应用程序</b></font></font></font></p>         </td>          <td width="160">           <p><font size="2" face="宋体">新建项目 -&gt; WCF结点</font></p>         </td>          <td width="167">           <p><font size="2" face="宋体">4.0</font></p>         </td>       </tr>        <tr>         <td width="171">           <p><font color="#008000"><font size="2"><font face="宋体"><b>WF</b><b>顺序服务</b></font></font></font></p>         </td>          <td width="160">           <p><font size="2" face="宋体">新建项目 -&gt; WCF结点</font></p>         </td>          <td width="167">           <p><font size="2" face="宋体">3.5</font></p>         </td>       </tr>        <tr>         <td width="171">           <p><strong><font color="#008000" size="2" face="宋体">WF状态机服务</font></strong></p>         </td>          <td width="160">           <p><font size="2" face="宋体">新建项目 -&gt; WCF结点</font></p>         </td>          <td width="167">           <p><font size="2" face="宋体">3.5</font></p>         </td>       </tr>        <tr>         <td width="171">           <p><b><font color="#ff8000" size="2" face="宋体">联合服务库</font></b></p>         </td>          <td width="160">           <p><font size="2" face="宋体">新建项目 -&gt; WCF结点</font></p>         </td>          <td width="167">           <p><font size="2" face="宋体">3.5/4.0</font></p>         </td>       </tr>        <tr>         <td width="171">           <p><font color="#400080"><font size="2"><font face="宋体"><b>WCF</b><b>服务</b></font></font></font></p>         </td>          <td width="160">           <p><font size="2" face="宋体">新建网站</font></p>         </td>          <td width="167">           <p><font size="2" face="宋体">3.0/3.5/4.0</font></p>         </td>       </tr>     </tbody></table> </div>  <p align="center"><b><font size="2" face="宋体">表1</font></b></p>  <p><b><font size="2" face="宋体"></font></b></p>  <p><font size="2"><font face="宋体"><font color="#008000"><b></b></font></font></font></p>  <p><font size="2"><font face="宋体"><font color="#008000"><b>WCF</b><b>服务库</b></font><b>、<font color="#008000">WF顺序服务</font>、<font color="#008000">WF状态机服务</font>：</b></font></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 启用调试（F5）默认会启动WCF服务主机（WCF Service Host）托管项目中的服务，并且会自动启用WCF测试客户端，请看图2：</font></p>  <p align="center"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WCF%20Service%20Library_2.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WCF%20Service%20Library_2.jpg"><font size="2" face="宋体"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="WCF Service Library" border="0" alt="WCF Service Library" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WCF%20Service%20Library_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WCF%20Service%20Library_thumb.jpg" width="669" height="386" /></font></a><font size="2" face="宋体"> </font></p>  <p align="center"><b><font size="2" face="宋体">图2</font></b></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 如果希望F5时，不启动WCF测试客户端，可以通过修改项目属性 -&gt; 调试 -&gt; 命令行参数来实现，如图3所示：</font></p>  <p align="center"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/NoWCFTestClient_2.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/NoWCFTestClient_2.jpg"><font size="2" face="宋体"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="NoWCFTestClient" border="0" alt="NoWCFTestClient" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/NoWCFTestClient_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/NoWCFTestClient_thumb.jpg" width="675" height="505" /></font></a><font size="2" face="宋体"> </font></p>  <p align="center"><b><font size="2" face="宋体">图3</font></b></p>  <p><b><font size="2" face="宋体"></font></b></p>  <p><font size="2"><font face="宋体"><font color="#0080ff"><b></b></font></font></font></p>  <p><font size="2"><font face="宋体"><font color="#0080ff"><b>WCF</b><b>服务应用程序</b></font><b>、<font color="#0080ff">WCF工作流服务应用程序</font>：</b></font></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 当在“解决方案资源管理器（Solution Explorer）”中，焦点选定在特定服务的.svc或.xamlx文件时，F5会启动WCF测试客户端。请看图4：</font></p>  <p align="center"><b><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WAP_2.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WAP_2.jpg"></a><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WAP_2.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WAP_2.jpg"><font size="2" face="宋体"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="WAP" border="0" alt="WAP" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WAP_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFWCFTestClient_D7D4/WAP_thumb.jpg" width="686" height="424" /></font></a></a><font size="2" face="宋体"> </font></b></p>  <p align="center"><b><font size="2" face="宋体">图4</font></b></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 如果希望F5时始终启动IE，可以在.csproj.user文件里增加EnableWcfTestClientForSVC属性配置以禁用WCF测试客户端：</font></p>  <blockquote>   <p><font size="2" face="宋体">&lt;Project&gt;</font></p>    <p><font size="2" face="宋体">&#160; &lt;ProjectExtensions&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160; &lt;VisualStudio&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160; &lt;FlavorProperties&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;WebProjectProperties&gt;</font></p>    <p><font size="2"><font face="宋体">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>&lt;EnableWcfTestClientForSVC&gt;False&lt;/EnableWcfTestClientForSVC&gt;</strong></font></font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/WebProjectProperties&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160; &lt;/FlavorProperties&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160; &lt;/VisualStudio&gt;</font></p>    <p><font size="2" face="宋体">&#160; &lt;/ProjectExtensions&gt;</font></p>    <p><font size="2" face="宋体">&lt;/Project&gt;</font></p> </blockquote>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 另外，在.csproj文件里还有EnableWcfTestClientForSVC属性的默认值设置。如果.csproj.user文件没有该属性的相关设置，则该属性则使用.csproj文件里默认值：</font></p>  <blockquote>   <p><font size="2" face="宋体">&lt;Project&gt;</font></p>    <p><font size="2" face="宋体">&#160; &lt;ProjectExtensions&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160; &lt;VisualStudio&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160; &lt;FlavorProperties&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;WebProjectProperties&gt;</font></p>    <p><font size="2"><font face="宋体">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>&lt;EnableWcfTestClientForSVCDefaultValue&gt;False&lt;/EnableWcfTestClientForSVCDefaultValue&gt;</strong></font></font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/WebProjectProperties&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160;&#160;&#160; &lt;/FlavorProperties&gt;</font></p>    <p><font size="2" face="宋体">&#160;&#160;&#160; &lt;/VisualStudio&gt;</font></p>    <p><font size="2" face="宋体">&#160; &lt;/ProjectExtensions&gt;</font></p>    <p><font size="2" face="宋体">&lt;/Project&gt;</font></p> </blockquote>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 下表是.csproj.user和.csproj文件相关属性的设置和启动客户端类型的逻辑关系： </font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p align="center">   <table border="1" cellspacing="0" cellpadding="0" width="800"><tbody>       <tr>         <td width="146">           <p><font size="2" face="宋体">.csproj.user</font></p>            <p><font size="2" face="宋体">文件设置</font></p>         </td>          <td width="146">           <p><font size="2" face="宋体">True</font></p>         </td>          <td width="146">           <p><font size="2" face="宋体">False</font></p>         </td>          <td width="121">           <p><font size="2" face="宋体">未设</font></p>         </td>          <td width="125">           <p><font size="2" face="宋体">未设</font></p>         </td>          <td width="114">           <p><font size="2" face="宋体">未设</font></p>         </td>       </tr>        <tr>         <td width="146">           <p><font size="2" face="宋体">.csproj</font></p>            <p><font size="2" face="宋体">文件设置 </font></p>         </td>          <td width="146">           <p><font size="2" face="宋体">True/False/未设</font></p>         </td>          <td width="146">           <p><font size="2" face="宋体">True/False/未设</font></p>         </td>          <td width="121">           <p><font size="2" face="宋体">True</font></p>         </td>          <td width="125">           <p><font size="2" face="宋体">False</font></p>         </td>          <td width="114">           <p><font size="2" face="宋体">未设</font></p>         </td>       </tr>        <tr>         <td width="146">           <p><font size="2" face="宋体">启动</font></p>            <p><font size="2" face="宋体">客户端类型</font></p>         </td>          <td width="153">           <p><font size="2" face="宋体">WCF测试客户端</font></p>         </td>          <td width="161">           <p><font size="2" face="宋体">IE</font></p>         </td>          <td width="151">           <p><font size="2" face="宋体">WCF测试客户端</font></p>         </td>          <td width="168">           <p><font size="2" face="宋体">IE</font></p>         </td>          <td width="178">           <p><font size="2" face="宋体">IE</font></p>         </td>       </tr>     </tbody></table> </p>  <p align="center"><b><font size="2" face="宋体">表2</font></b></p>  <p align="center"><strong><font size="2" face="宋体"></font></strong></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; 例如，在一个利用源代码控制的项目组中，.csproj.user文件不会被共享，而.csproj文件会被共享。如果只希望改变个人的WCF测试客户端的启动行为，则应该修改.csproj.user文件；如果希望改变开发这个项目的所有人的启动行为，则应修改.csproj文件。</font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2"><font face="宋体"><b><font color="#ff8000"></font></b></font></font></p>  <p><font size="2"><font face="宋体"><b><font color="#ff8000">联合服务库</font></b><b>：</b></font></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; WCF测试客户端并不能对这种服务项目进行测试，所以F5时并不会自动启动WCF测试客户端。</font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2"><font face="宋体"><font color="#400080"><b></b></font></font></font></p>  <p><font size="2"><font face="宋体"><font color="#400080"><b>WCF</b><b>服务（网站）</b></font><b>：</b></font></font></p>  <p><font size="2" face="宋体">&#160;&#160;&#160; F5时不会自动启动WCF测试客户端。如果希望获得和<font color="#0080ff"><b>WCF</b><b>服务应用程序</b></font>相同的启动行为，可以修改C:\Users\&lt;username&gt;\AppData\Local\Microsoft\WebsiteCache\websites.xml文件（XP/2003系统中文件在相似位置）：</font></p>  <blockquote>   <p><font size="2" face="宋体">&lt;DesignTimeData&gt;</font></p>    <p><font size="2" face="宋体">&#160; &lt;Website RootUrl=&quot;C:\&quot; CacheFolder=&quot;WCFService1&quot; <strong>EnableWcfTestClientForSVC=&quot;true&quot;</strong>/&gt;</font></p>    <p><font size="2" face="宋体">&lt;/DesignTimeData&gt;</font></p> </blockquote>  <p><font size="2" face="宋体">&#160;&#160;&#160; 注意在修改websites.xml文件之前请先关闭Visual Studio，否则Visual Studio关闭时会重写覆盖websites.xml文件。</font></p>  <p><font size="2" face="宋体">&#160;</font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>  <p><font size="2" face="宋体"></font></p>]]></content:encoded>
    </item>
    <item>
      <title>IIS托管的WCF服务的常见Setup问题</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/iiswcfsetup</link>
      <pubDate>Sun, 13 Dec 2009 21:31:57 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2009/12/13/iiswcfsetup/</guid>
      <description><![CDATA[微软服务器与开发工具事业部 黄捷  如果你创建寄宿在IIS中的WCF Service网站项目，（图1显示怎样创建这样的网站项目），或者你把你的WCF Web Application项目或者WCF...]]></description>
      <content:encoded><![CDATA[<p>微软服务器与开发工具事业部 黄捷</p>  <p>如果你创建寄宿在IIS中的WCF Service网站项目，（图1显示怎样创建这样的网站项目），或者你把你的WCF Web Application项目或者WCF Service网站项目发布或部署到IIS网站服务器上后，你可以用网页浏览器去访问你的网站。如果你在尝试打开这些网页时无法看到正确的页面显示，或者看到错误提示页面(图2是错误提示页面的一个例子: HTTP Error 500.21 – Internal Server Error Handler “svc-Integrated” has a bad module “ManagedPipelineHandler” in its module list)，下面是最常见的问题和解决办法。</p>  <blockquote>   <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image3.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image3.png"><img title="Image" style="border-top-width: 0px; display: block; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="412" alt="Image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image3_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image3_thumb.png" width="584" border="0" /></a></p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 图1 <a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image6.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image6.png"><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="415" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image6_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image6_thumb.png" width="584" border="0" /></a>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 图2</p> </blockquote>  <p>常见问题与解决办法：</p>  <p>1. 检查IIS是否正确安装和运行</p>  <p>你需要保证你的IIS服务器已经正确安装并正常运行。这里我们不讨论IIS安装的方法(你可你根据你的Windows版本和需要的IIS版本去<a href="https://www.bing.com">bing</a>中搜索)， 只给出简单的验证方法。如图2所示，在IE地址栏中输入<a href="https://localhost">https://localhost</a>， 如果你看到如图所示的页面或者类似的其他版本IIS的默认页面。那么就说明IIS已经在正常运行了。</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image9.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image9.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="502" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image9_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image9_thumb.png" width="584" border="0" /></a>&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 图3</p>  <p>2. 正确注册安装ASP.net </p>  <p>打开Visual Studio命令行提示工具（Start-&gt;All Programs-&gt;Visual Studio-&gt;Visual Studio Tools-&gt;Visual Studio Command Prompt， 如果你的OS是Windows Vista及以后的版本，你需要以管理员身份打开），运行”aspnet_regiis.exe -i”。在命令运行完成后重新尝试你的网站。</p>  <p>3. 在IIS中配置正确的Application Pool </p>  <p>在IIS管理工具(IIS Manager)中找到你的Website， 选中。在右侧的面板中点击Basic Settings。 你将看到如图3所示的弹出窗口，其中有你正在使用的Application Pool的信息。 选择IIS管理工具中的Applications Pools节点。选中你在使用的Application Pool， 点击右侧的Basic Settings。 你将看到如图4所示的弹出窗口。确定其中的.NET Framework版本是v4.0.xxxxx。如果不是，这也许就是你看到错误页面的原因。尝试在图2中把它改成v4.0或者在图3中选择”Select…”， 更改成其他的使用.NET Framework v4.0的Application Pool。</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image12.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image12.png"><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="319" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image12_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image12_thumb.png" width="456" border="0" /></a></p>  <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 图4&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image15.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image15.png"><img title="image" style="border-top-width: 0px; display: block; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="247" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image15_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/IISWCFSetup_BD0A/image15_thumb.png" width="271" border="0" /></a>&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 图5</p>  <p>&#160;</p>  <p>4. 安装注册WCF组件</p>  <p>WCF没有正确的在IIS中注册也许是导致看到错误页面的最常见原因。如果你在安装Visual Studio后才安装IIS， 那么你就很可能遇到这样的问题。打开Visual Studio命令行提示工具（Start-&gt;All Programs-&gt;Visual Studio-&gt;Visual Studio Tools-&gt;Visual Studio Command Prompt， 如果你的OS是Windows Vista及以后的版本，你需要以管理员身份打开），运行” ServiceModelReg.exe –ia”。 命令完成后再次访问你的WCF 网站。</p>]]></content:encoded>
    </item>
    <item>
      <title>介绍VS2010中WCF 工具的新功能</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/vs2010wcf</link>
      <pubDate>Tue, 01 Dec 2009 03:45:00 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2009/12/01/vs2010wcf/</guid>
      <description><![CDATA[微软服务器与开发工具事业部&nbsp;薛敏敏
如果你在VS2008中开发过WCF服务应用，那你应该使用过集成在其中的WCF开发工具。如果你刚刚开始使用WCF技术，那么可以先阅读这两篇博文对这些WCF...]]></description>
      <content:encoded><![CDATA[<P>微软服务器与开发工具事业部&nbsp;薛敏敏</P>
<P>如果你在VS2008中开发过WCF服务应用，那你应该使用过集成在其中的WCF开发工具。如果你刚刚开始使用WCF技术，那么可以先阅读这两篇博文对这些WCF开发工具有一个初步的了解：<A href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/01/12/vs2008-wcf.aspx" mce_href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/01/12/vs2008-wcf.aspx">VS2008中的WCF开发工具</A>和<A href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/01/12/vs2008-sp1-wcf.aspx" mce_href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/01/12/vs2008-sp1-wcf.aspx">VS2008 SP1中WCF开发工具的新功能和增强点</A>。</P>
<P>而在VS2010中我们团队继续为WCF开发工具添加了一系列新功能，希望能为大家提供更好的开发体验。在本文中我将它们逐一罗列出来：</P>
<P><B>在工作流4.0</B><B>应用中添加服务引用</B></P>
<P>当你在一个工作流4.0应用中添加服务引用时，你会看到和以前一样的添加服务引用对话框，可以输入服务的mex或wsdl地址，来生成客户端的代理。不同于以往生成的代码，这时还会生成一组基于XAML的预先配置好的消息活动，和服务中的方法一一对应。当你build你的工作流4.0应用后，这些活动会加到Toolbox中，你可以拖拽使它们成为你的工作流的一部分，并且使用它们来调用服务。</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_4.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_4.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_4.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_1.png" width=244 height=198 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_1.png"></A> <A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_6.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_6.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_6.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_2.png" width=300 height=287 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_2.png"></A> <A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_8.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_8.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_8.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_3.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_3.png" width=188 height=198 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_3.png"></A> </P>
<P><B></B></P>
<P><B>新的WCF</B><B>工作流服务模板</B></P>
<P>在.net4.0中，我们新添加了一个新的WCF工作流服务应用模板，帮助创建可长时间运行的工作流服务。</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_10.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_10.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_10.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_4.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_4.png" width=481 height=232 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_4.png"></A>&nbsp; <A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_12.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_12.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_12.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_5.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_5.png" width=166 height=167 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_5.png"></A></P>
<P><B></B></P>
<P><B>简化配置的WCF</B><B>服务模板</B></P>
<P>在WCF4.0中对配置作了简化，包括：使&lt;Services&gt;部分变为可选的，在运行时获得服务的终结点信息；支持服务行为和绑定配置、终结点配置的名字为空等等。所以在4.0的服务模板中也在配置文件中体现了这些简化的配置，以下是WCF服务应用模板的例子：</P>
<TABLE border=0 cellSpacing=0 cellPadding=1 width=724>
<TBODY>
<TR>
<TD vAlign=top width=722>
<P>&lt;system.serviceModel&gt;</P>
<P>&lt;behaviors&gt;</P>
<P>&lt;serviceBehaviors&gt;</P>
<P>&lt;behavior&gt;</P>
<P>&lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;</P>
<P>&lt;serviceMetadata httpGetEnabled="true"/&gt;</P>
<P>&lt;!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --&gt;</P>
<P>&lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;</P>
<P>&lt;/behavior&gt;</P>
<P>&lt;/serviceBehaviors&gt;</P>
<P>&lt;/behaviors&gt;</P>
<P>&lt;/system.serviceModel&gt;</P></TD></TR></TBODY></TABLE>
<P><B>在WCF</B><B>和工作流服务应用中F5</B><B>自动启动WCF</B><B>测试客户端</B></P>
<P>在VS2008中，只支持在WCF服务库模板中F5自动启动WCF测试客户端。在VS2010 中，从WCF和工作流服务应用模板创建的WCF服务应用也支持F5自动启动WCF测试客户端。在F5前，请先选中特定服务的.svc或.xamlx文件。</P>
<P><B></B></P>
<P><B>WCF</B><B>测试客户端支持DataSet</B><B>类型</B></P>
<P>WCF测试客户端可以测试WCF服务或者.NET服务中使用的DataSet数据类型。</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_14.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_14.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_14.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_6.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_6.png" width=485 height=297 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_6.png"></A> </P>
<P><B></B></P>
<P><B>在WCF</B><B>和工作流服务应用中全新的服务发布机制</B></P>
<P>当基于WCF或WCF工作流服务应用模板创建服务应用后，你可以使用全新的发布机制来部署这些服务应用。对于WCF服务库应用还是继续沿用老的发布机制。</P>
<P>Web包：在VS2010中使用MSDeploy打包应用，在Web包中包含了IIS设置信息，相关的web内容，SQL服务器数据库，安全认证，GAC组件，等等。所以Web包可以直接拿到任何服务器上发布。</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_16.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_16.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_16.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_7.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_7.png" width=244 height=152 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_7.png"></A> <A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_18.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_18.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_18.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_8.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_8.png" width=415 height=242 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_8.png"></A> </P>
<P>配置文件转换：在VS2010中引入了XML Document Transform (XDT)，用于灵活地转换开发时或发布时的配置文件。在配置转换文件web.debug.config, web.release.config中存储在web.config文件中需要被替换的内容。</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_20.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_20.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_20.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_9.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_9.png" width=244 height=79 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_9.png"></A> <A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_22.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_22.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_22.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_10.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_10.png" width=187 height=220 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_10.png"></A> </P>
<P>服务发布一步到位：VS2010支持使用IIS远程管理服务把应用发布到远程服务器上。通过创建好特定的profile，可以支持一键式的发布。</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_24.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_24.png" mce_href="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_24.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_11.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_11.png" width=287 height=403 mce_src="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/VS2010WCF_114F2/image_thumb_11.png"></A> </P>
<P>以上是对VS2010中WCF工具的简单小结。在后续的文章中，我们将会对其中的一些功能作更详细的描述。</P>
<P><B>有用的链接：</B></P>
<P>WCF 和WF新功能:&nbsp; <A href="https://msdn.microsoft.com/en-us/netframework/cc896557.aspx" mce_href="https://msdn.microsoft.com/en-us/netframework/cc896557.aspx">https://msdn.microsoft.com/en-us/netframework/cc896557.aspx</A></P>
<P>WCF，WF和AppFabric的网上实验室： <A href="https://msdn.microsoft.com/en-us/cc814756.aspx" mce_href="https://msdn.microsoft.com/en-us/cc814756.aspx">https://msdn.microsoft.com/en-us/cc814756.aspx</A></P>]]></content:encoded>
    </item>
    <item>
      <title>MVP Day: WCF REST课程预告和意见征询</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/mvp-day-wcf-rest</link>
      <pubDate>Fri, 27 Nov 2009 03:51:00 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2009/11/27/mvp-day-wcf-rest/</guid>
      <description><![CDATA[&nbsp;注：该课程的演讲稿和示例程序已经上传：https://blogs.msdn.com/wcftoolsteamblogcn/archive/2010/01/11/wcf-rest-2009-m...]]></description>
      <content:encoded><![CDATA[<P>&nbsp;注：该课程的演讲稿和示例程序已经上传：<A href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2010/01/11/wcf-rest-2009-mvp-day.aspx">https://blogs.msdn.com/wcftoolsteamblogcn/archive/2010/01/11/wcf-rest-2009-mvp-day.aspx</A></P>
<P>&nbsp;我们将于12/10 - 12/11的MVP Day作一个关于WCF REST的讲座。下面是这个讲座的简介和主要方向。希望大家能在会前多给意见，使我们的讲座更有针对性。</P>
<P>主题；使用WCF创建RESTful服务</P>
<P>REST作为一种创建服务架构风格，诞生多年并日趋流行，目前它已经成为一种事实上的标准和许多企业对外发布服务的首选。而微软也在WCF程序框架中开始提供了对REST服务的支持。在这个框架下，我们可以使用WCF技术来方便地创建REST服务。在这个讲座中，我们将介绍REST和WCF的一些基本概念，WCF如何实现REST，以及如何来使用WCF创建一个REST风格的服务。在这个Session中，我们将讨论到：</P>
<P><BR>1.回顾REST的基本概念，它的优势，它的使用情况。</P>
<P>2.通过一个简单的例子引入一个REST风格的程序，同时讨论WCF内部是怎么实现REST框架的</P>
<P>3.演示一个更加具体的例子（微博客服务类似于Twitter）的开发，来一步一步介绍怎么使用WCF开发REST，包括如何处理URI，处理返回的资源格式，设置安全性，在IIS上进行部署等等。</P>]]></content:encoded>
    </item>
    <item>
      <title>WCF中的REST架构三 （支持AJAX的WCF Service – 使用服务）</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/wcfrest-ajaxwcf-service</link>
      <pubDate>Sun, 07 Jun 2009 19:32:59 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2009/06/07/wcfrest-ajaxwcf-service/</guid>
      <description><![CDATA[在昨天的文章WCF中的REST架构二（支持AJAX的WCF服务 - 创建服务）中， 我介绍了一个包含一些ASP.NET AJAX 客户端库控件的入门解决方案。这个解决方案还没有具体实现的代码,...]]></description>
      <content:encoded><![CDATA[<p>在昨天的文章<a href="https://blogs.msdn.com/wcftoolsteamblogcn/archive/2009/01/12/wcf-rest-ajax-wcf.aspx">WCF中的REST架构二（支持AJAX的WCF服务 - 创建服务）</a>中， 我介绍了一个包含一些ASP.NET AJAX 客户端库控件的入门解决方案。这个解决方案还没有具体实现的代码, 等着我们为它编写支持AJAX的WCF服务和客户端代码去调用这些服务. 我随后介绍了如何利用webHttpBinding和enableWebScript 这两个endpoint behavior去实现一个支持AJAX的WCF服务。</p>  <p>在本篇中，我将会编写客户端的代码去调用我们的服务。 你可能还记得我们上一篇中的Catalog.aspx (应用程序中包含AJAX控件的主要页面)有一个空方法GetData。这个方法在页面初始化的时候，以及在用户在不同商品的不同页面间跳转时被调用。这个方法就是我们要编写代码去调用我们的服务的地方。</p>  <p><b></b></p>  <p><b>注册服务</b></p>  <p>在我过于深入之前，让我们先短暂停留一会儿。之前我已经编写了一个支持AJAX的WCF服务，但是这究竟意味着什么？从本质上来说，这意味着我们的服务有一个endpoint behavior, 它允许我们创建客户端的AJAX代理类，用几行代码就可以调用我们提供的服务。然后，我们仅仅只需用ScriptManager注册我们的服务就可以实现将这个代理类转化成”流”(stream)传给浏览器。请看下面的代码：</p>  <p>&lt;asp:ScriptManager ID=&quot;scriptManager&quot; runat=&quot;server&quot;&gt;</p>  <p>&lt;Scripts&gt;</p>  <p>&lt;asp:ScriptReference Path=&quot;Controls/Catalog.js&quot; /&gt;</p>  <p>&lt;asp:ScriptReference Path=&quot;Controls/HighlightImageBehavior.js&quot; /&gt;</p>  <p>&lt;asp:ScriptReference Path=&quot;Controls/ShoppingCart.js&quot; /&gt;</p>  <p>&lt;asp:ScriptReference Path=&quot;Controls/LoginStatus.js&quot; /&gt;</p>  <p>&lt;/Scripts&gt;</p>  <p>&lt;Services&gt;</p>  <p>&lt;asp:ServiceReference Path=&quot;~/CatalogService.svc&quot; /&gt;</p>  <p>&lt;/Services&gt;</p>  <p>&lt;/asp:ScriptManager&gt;</p>  <p></p>  <p>如果你对ScriptManager不熟悉，他是一个ASP.NET控件，责任是按需分发页面必需的javacript. 如果你有ASP.NET AJAX服务器控件的经验，你会知道它们就是通过ScriptManager来交流他们的脚本需求的。ScriptManager然后给出相应的脚本元素, 在上面的代码中，这个Script节点包含了4个指向专用于这个购物示例应用程序的ASP.NET AJAX客户端库的引用。他们与我们当前的议题(调用WCF服务)并不相关。重要的部分是Service节点。你会注意到这个节点包含了一个指向CatalogService.svc文件路径(即服务的路径)的 ServiceReference。 我们这里主要做的就是把这个支持AJAX的WCF服务注册到ScriptManager中来。</p>  <p>通过注册，我们告诉ScriptManager为网页分发一个指向一个HttpHandler的script元素，它知道如何生成服务的客户端代理。为了展示这一点，我将直接在浏览器中打开这个网页，然后在页面上点击右键，选择”查看源码”。往下翻动，下面那是我找到的内容：</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_2_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_2_2.png"><img title="image_2" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="181" alt="image_2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_2_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_2_thumb.png" width="512" border="0" /></a> </p>  <p><b></b></p>  <p><b>代理类</b></p>  <p>如果你想看一下客户端代理的代码(你应该看一下)，在你的网页URL后面加上CatalogService.svc/jsdebug。在我的例子中，完整的URL是: <a href="https://localhost:50183/ClientStore/CatalogService.svc/jsdebug">https://localhost:50183/ClientStore/CatalogService.svc/jsdebug</a>。打开后你会得到如下的对话框：</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_1_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_1_2.png"><img title="image_thumb_1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="260" alt="image_thumb_1" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_1_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_1_thumb.png" width="351" border="0" /></a> </p>  <p>我将代理保存到我桌面的本地文件，更名为proxy.js。然后我将这个文件拖放到我的好友Visual Studio中去。以下是我看到的部分:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_2_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_2_2.png"><img title="image_thumb_2" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="253" alt="image_thumb_2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_2_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_2_thumb.png" width="565" border="0" /></a> </p>  <p>第一个值得注意的地方是这里的代理利用了ASP.NET 客户端库。在这些库中，我们”.NET化”了JavaScript。 我们添加了命名空间(namespace)，类等一系列概念。如果你对更详细的ASP.NET AJAX客户端库感兴趣的话，可以参看我写的<a href="https://blogs.msdn.com/bags/archive/2007/06/07/latest-asp-net-client-libraries-webcast-sample-code-and-links-to-all-sessions.aspx">12 part webcast series</a>。里面介绍了几乎ASP.NET 客户端类实现的所有方面。</p>  <p>第二个值得我们注意的地方是，AJAX类的命名空间和我们在第二篇里面创建的服务的命名空间是一致的。最后一件我想讨论的是，GetPatients操作(operation)被加到了AJAX类的原型(prototype)当中（在JavaScript当中，每一个对象都有一个对象原型。这个原型就是用来存放那些非实例特有的成员，例如方法，的正确地方）。你会注意到这里的操作的签名(signature)基本上是和我们服务操作的签名是一致的。不同的地方是这里多了调用成功或失败的回调函数，以及context参数。这些参数是必要的，因为回调函数是在异步模式下被调用的。换一种说法, 我们的服务操作被”AJAX化”了。现在调用我们的服务就变得很简单了：1) 创建一个代理类的实例。 2) 调用代理的GetPatients 方法。事实上，我们还有第三步和第四步要做的事情，我们还需要编写我们的回调方法。让我来通过扩充GetData的代码来给大家演示。</p>  <p><b></b></p>  <p><b>完成调用</b></p>  <p>在你刚开始创建你的代理实例的时候就会注意到的是，VS2008为代理类提供了IntelliSense支持。见下图:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_3_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_3_2.png"><img title="image_thumb_3" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="223" alt="image_thumb_3" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_3_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_3_thumb.png" width="469" border="0" /></a> </p>  <p>下面是GetData的完整代码：</p>  <p>// This function calls the GetProductGrouping AJAX method, </p>  <p>// using the script proxy</p>  <p>function GetData()</p>  <p>{</p>  <p>var startIndex = ((currentPage) * pageSize);</p>  <p>var proxy = new shopping.services.CatalogService();</p>  <p>proxy.GetProductGrouping(startIndex, pageSize, ProductsReturnedEventHandler, ProductsFailedEventHandler, null);</p>  <p>}</p>  <p>我们曾经需要为实现正确的行为写上几十上百行代码，而不是这里的两行。当提到这点的时候，我是在特别针对那些已经不必再由我们自己去实现的那些串行化(serialize)和反串行化(deserialize)代码。如果你真的要自己去实现所有的代码的话，你必须写代码把你的客户端参数(以及方法信息，如果你用POST的话)串行化成例如JSON或者XML那样的格式。然后你需要在服务器端去写代码反串行化你的那些参数，调用服务，得到.NET类型的服务响应。接着你还需要将这些.NET类型再串行化回JSON或者XML格式（或者其他你选择的格式）并将他们以异步的方式传回客户端。最后，你还需要在客户端将这些数据流反串行化给JavaScript。 现在，.NET已经帮你打理好了这所有的一切。</p>  <p>在第二篇中，我讨论了ProductsReturnedEventHandler是如何简单的得到一个AJAX控件，设置两个属性的值（他们其中之一的值被设为服务调用响应的返回值），以及调用一个方法去做DOM插入。让我们在Visual Studio调试功能和WebDevHelper的帮助下来看一下往返发送的数据内容。第一个我想让大家看的是在做完所有串行化/反串行化以后传递给回调方法的参数。请注意传递给回调方法的JavaScript类型是我们在第二篇中详细讲述的.NET类型的近似表示。 就连.NET的类型名也通过”__type”被传递了。看下图：</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_10_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_10_2.png"><img title="image_10" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="332" alt="image_10" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_10_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_10_thumb.png" width="571" border="0" /></a> </p>  <p>下一个我要展示给大家的是真正的请求和响应（这里借助Nikhil的WebDevHelper工具）：</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_6_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_6_2.png"><img title="image_thumb_6" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="449" alt="image_thumb_6" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_6_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_6_thumb.png" width="464" border="0" /></a> </p>  <p>我们也可以看到请求和响应的内容：</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_7_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_7_2.png"><img title="image_thumb_7" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="206" alt="image_thumb_7" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_7_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_7_thumb.png" width="489" border="0" /></a> </p>  <p><b></b></p>  <p><b>控制如何曝露(Expose)</b><b>服务</b></p>  <p><b></b></p>  <p>你在上面注意到，服务默认是以POST的方式曝露的。甚至大多数自由REST主义者(liberal RESTafarians)看到这个都会皱眉头。GET才是大多数人对于获取操作的实际选择。还有，你会注意到默认的数据表达格式（数据串行化方式）是JSON。但万一如果你并不想用JSON,而想用XML的某种形式那该怎么做呢？结论是，通过使用enableWebScript endpoint behavior你可以控制两样东西。通过webHttp endpoint behavior, 可以控制更多的东西。你将在以后的��章中读到这些内容。</p>  <p>为了控制操作的Http 动词(Verb)， 你可以用下面的一个或两个属性来修饰你的操作：</p>  <ul>   <li>[WebGet] – 将Http 动词设成GET </li>    <li>[WebInvoke(Method=”…”)] – 将Http 动词设成GET以外的任意动词。不过，当使用了enableWebScript的时候，只有POST是被支持的。其他的动词只被webHttp endpoint behavior支持。 </li> </ul>  <p>WebGet和WebInvoke都有一个ResponseFormat参数。你可以将它设成WebMessageFormat.Xml 或者WebMessageFormat.Json。你可以从下面的代码看到我如何设置这些选择。</p>  <p>[OperationContract]</p>  <p>[WebGet(ResponseFormat=WebMessageFormat.Xml)]</p>  <p>public ProductGroupingData GetProductGrouping(int startIndex, int pageSize)</p>  <p>为了演示这些设置的结果，我打开另一个的页面调用这个服务。下面是WebDevHelper里面的结果：</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_8_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_8_2.png"><img title="image_thumb_8" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="354" alt="image_thumb_8" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_8_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCFService_674C/image_thumb_8_thumb.png" width="527" border="0" /></a> </p>  <p><b></b></p>  <p><b></b></p>  <p><b>支持AJAX</b><b>的REST</b><b>服务的总结</b></p>  <p>在这两篇文章中， 我实现了一个支持AJAX的WCF服务和一个使用这个服务的AJAX客户端。那么，这个服务是否落脚在了REST领域中了呢？如果是的话，在哪里？我相信它满足了RESTFUL的标准。首先，它没有用到SOAP包，这无疑迈出了第一步。当我们比照不同的RESTfulness的不同标准的时候，我们发现我们的实现很明显落在了 LO REST这一边。考虑下面几点：</p>  <ul>   <li>我们只用了两个Http 动词，GET 和POST。我们把PUT和DELETE都忽略了。在一个HI REST场景中，人们可以说，通过Http动词就足以理解调用的目的（GET用来获取，PUT用来插入或更新，DELETE用来删除，POST用来添加 – 或者一些类似的任务）。在我们的例子中，我们反复使用了POST。我们必须通过检查请求的内容才能够理解调用的目的。结论 -&gt; LO </li>    <li>在URI可定位性(addressability)这方面，我们在GET中使用查询字符串。更进一步，我们的实现感觉上有点RPC的意味。结论-&gt; LO </li>    <li>在表达格式这方面，我们可以选择任意二者之一。虽然JSON是标准，但他并不影响数据的含义，而只是一种语法罢了。并且，你当然也可以返回一种标准，在你的服务中接收XML的表示。结论-&gt; 无法确定 </li> </ul>  <p>请不要把我上面这段蠢话误解为在给这个服务打分。我不是这个意思，我喜欢这里的支持AJAX的实现。我只是想给你们一点东西去回味咀嚼它在REST领域中的定位。</p>  <p>在后面的文章中，我将会给大家展示一种更靠近于HI REST 一端的实现。</p>]]></content:encoded>
    </item>
    <item>
      <title>WCF中的REST架构二 （支持AJAX的WCF服务 - 创建服务）</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/wcfrest-ajaxwcf</link>
      <pubDate>Mon, 12 Jan 2009 03:24:43 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2009/01/12/wcfrest-ajaxwcf/</guid>
      <description><![CDATA[我在昨天 的文章WCF中的 REST架构一（REST 概述）谈了REST的基本概要，并提出了从HI REST （高REST）到 LO REST (低REST)...]]></description>
      <content:encoded><![CDATA[<p>我在昨天 的文章WCF中的 <a href="https://blog.csdn.net/WCFToolsBloggers/archive/2008/09/02/2865038.aspx"><u>REST架构一（REST 概述）</u></a>谈了REST的基本概要，并提出了从HI REST （高REST）到 LO REST (低REST) 的RESTFULness（REST度）的概念。在今天的文章中，我将详细介绍大家可能最为熟悉的REST风格的 WCF 服务：支持AJAX的服务。此类服务应属于LO REST的范畴。现在很多人直觉地将“好”等同于“高大全”，因而低估了这种LO REST实现的价值。本篇将告诉你这决非事实，支持AJAX的WCF服务是足够强大的。    <br /><strong>解决方案的背景信息</strong>    <br />我有一个底层工作已基本完整的<a href="https://www.robbagby.com/robbagby/Presentations/RESTBlogSeries/AJAXFriendlyStarterCode.zip"><u>初始解决方案</u></a>，大部分代码是作为<a href="https://blogs.msdn.com/bags/archive/2007/06/07/latest-asp-net-client-libraries-webcast-sample-code-and-links-to-all-sessions.aspx"><u>12集AJAX 客户库Webcast 系列</u></a>的组成部分。提供这个初始解决方案的目的是为了让我更好地展现支持AJAX的WCF服务的强大能力，避免现场创建一个这样的服务然后再与AJAX 客户应用集成所需的冗长步骤（如何你认为我创建的范例应用乏善可陈，请试一下<a href="https://www.supersefer.com/he/"><u>Supersefer</u></a>，这是一个基于这个范例的希伯来文网上商店）。在这个初始解决方案中请特别注意两个ASP.Net AJAX 控件: Catalog.js和ShoppingCart.js. 下面的截图就是这两个控件的显示    <br /><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_2.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="211" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_thumb.png" width="602" border="0" /></a>     <br />Catalog控件是本篇的重要操作对象，它的任务是接受一个特定的数据结构，显示一页产品信息，作绑定用途，并在用户选中某样产品或者点击浏览控件的时候出发消息，至于该控件是如何与宿主页（Catalog.aspx）交互，大家可以在前面提到的Webcast系列中找到。就本篇而言，我们只要关注Catalog.aspx（宿主页）中的下列代码片段，里面有一个GetData() 方法。等我们实现了WCF服务之后，就在这个方法里调用它。我们会给WCF服务传入诸如startIndex（起始索引）和pageSize（页的大小）之类的参数（服务的返回数据将是指定页数的产品信息）， 以及几个回调方法（服务调用成功或失败后被回调）。下面也给出了调用成功的回调方法。该方法直接获取了指向catalog控件的引用（$get 在 asp.net的AJAX中用来指向一个控件）。然后它将设定当前页的索引值，再用传入回调函数的数据，也就是我们的WCF有效荷载，来设定productInfo属性。最后，该函数调用控件的dataBind方法，这个方法直接基于存储在productInfo属性中的数据做了一些DOM注入。    <br /><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_4.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_4.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="392" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_thumb_1.png" width="506" border="0" /></a>     <br /><b>     <br />添加服务      <br /></b>添加一个支持AJAX的 WCF 服务相当简单。第一步就是使用'AJAX-enabled WCF Service'模板添加服务。过程如下：在Solution Explorer里面选择”Add New Item’ &gt; 选择'AJAX-enabled WCF Service' &gt; 将其命名为 CatalogService.cs &gt; 点击 ‘Add’.    <br /><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_6.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_6.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="381" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_thumb_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTAJAXWCF_E6B2/image_thumb_2.png" width="572" border="0" /></a>     <br />模板看起来相当神奇，其实它不过是添加了一些特定的文件，并更改了另一些文件（通常是*.config文件）而已。如果你是按照我的步骤，那么这个模板做了下列事情：    <br />1. 在项目根目录下添加CatalogService.svc文件    <br />2. 在app_code目录下添加CatalogService.cs文件    <br />3. 在web.config内配置服务    <br /><b>分析一下生成的文件     <br /></b>我们来看一下上面模板生成的文件并稍加讨论：    <br /><strong>CatalogService.svc</strong>    <br />&lt;%@ ServiceHost Language=&quot;C#&quot;    <br />Debug=&quot;true&quot;    <br />Service=&quot;CatalogService&quot;    <br />CodeBehind=&quot;~/App_Code/CatalogService.cs&quot; %&gt;    <br />*.svc文件可以类比于*.asmx文件。如果该服务在IIS或者WAS上运行，这个文件就作为服务的可定位资源。换句话说，*.svc 就是你服务的的基址。这个文件里我们只需注意两个属性：首先是Service属性，该属性被设为实现该服务的CLR类型名（你可以在app_code目录下的CatalogService.cs中找到该类型）。第二个就是指向实现文件的CodeBehind属性。    <br />你无需修改svc 文件的内容，我只是为了向你展示该文件就是作为服务的base地址。    <br /><b>web.config     <br /></b>&lt;system.serviceModel&gt;    <br />&lt;behaviors&gt;    <br />&lt;endpointBehaviors&gt;    <br />&lt;behavior name=&quot;CatalogServiceAspNetAjaxBehavior&quot;&gt;    <br />&lt;enableWebScript /&gt;    <br />&lt;/behavior&gt;    <br />&lt;/endpointBehaviors&gt;    <br />&lt;/behaviors&gt;    <br />&lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&quot;true&quot; /&gt;    <br />&lt;services&gt;    <br />&lt;service name=&quot;CatalogService&quot;&gt;    <br />&lt;endpoint address=&quot;&quot;    <br />behaviorConfiguration=&quot;CatalogServiceAspNetAjaxBehavior&quot;    <br />binding=&quot;webHttpBinding&quot;    <br />contract=&quot;CatalogService&quot; /&gt;    <br />&lt;/service&gt;    <br />&lt;/services&gt;    <br />&lt;/system.serviceModel&gt;    <br />如果熟悉WCF，你一定知道WCF的配置是位于system.serviceModel节点下。你会看到3个子节点：behaviors, serviceHostingEnvironment和serivces:    <br />1. Services: 文件内已经有一个名为CatalogService的服务，与实现服务的类名一致。在Service节点下，你可以看到Endpoint，它包含了服务的ABCs：Address(地址)， binding （绑定）和contract （协定）.    <br />&#160;&#160;&#160; a. Address: 你会发现地址是空的 ，不必担心，因为svc文件会作为基    <br />&#160;&#160;&#160; b. Binding: webHttpBinding是WCF3.5提供的可以让服务以REST方式发布的新型绑定。这个绑定有两种模式,你可以通过特定的终结点行为来指定模式（通过设定behaviorConfiguration)    <br />&#160;&#160;&#160; c. Contract: contract指定了WCF服务提供的功能。该属性被设为一个已经定义好的服务协定。要定义一个服务协定，你可以用ServiceContract修饰一个接口或者类。被ServiceContract修饰的接口或者类中，所有由OperationContract修饰的方法将被作为服务的操作暴露给客户。一般来说用接口做服务协定是更好的做法，这样做的好处是分离了协定与具体实现。 但在我们使用的模板中却使用了类的方法，也就是说，接口是从类自动推断出来的（接口推断）。    <br />&#160;&#160;&#160; d. BehaviorConfiguration: 对于webHttpBinding, 你需要将该属性设为一个拥有webHttp或enableWebScript子节点的终结点行为。    <br />2. Behaviors: 将behaviors加入到服务或者服务终结点的目的在于改变runtime的默认行为或者加入定制的扩展。你会发现我们使用的模板已经声明了一个名为CatalogServiceAspNetAjaxBehavior的终结点行为. 该行为有一个enableWebScript 元素。enableWebScript是两种可能的终结点行为之一，另一种就是webHttp。事实上enableWebScript是webHttp用来提供AJAX 功能（比如生成客户端代理）的子类     <br />3. ServiceHostingEnvironment: 跟ASP.Net运行的WCF服务的默认配置是让两者互不干扰 例如，ASP.NET runtime 不参与WCF请求的处理. WCF服务也不能使用ASP.NET context 和 session 这样的功能.<del cite="mailto:Lei%20Zhang" datetime="2008-09-09T11:16"> </del>而我们这里的配置是将aspNetCompatibilityEnabled 设为true, 在这种设置下WCF请求就会加到ASP.Net 的请求流水线里了。    <br />*要使WCF支持REST，只要在该配置文件中注意最重要的两点：1）binding应设为webHttpBinding 2) endpoint behavior要设定为webHttp或enableWebScript    <br /><b>     <br />CatalogService.cs      <br /></b>[ServiceContract(Namespace = &quot;&quot;)]    <br />[AspNetCompatibilityRequirements(RequirementsMode =    <br />AspNetCompatibilityRequirementsMode.Allowed)]    <br />public class CatalogService    <br />{    <br />// Add [WebGet] attribute to use HTTP GET    <br />[OperationContract]    <br />public void DoWork()    <br />{    <br />// Add your operation implementation here    <br />return;    <br />}    <br />// Add more operations here and mark them with [OperationContract]    <br />}    <br />在这里我们就真得做点儿事儿了。如果已经读了上面的内容，你应该已经注意到我们已经用接口推断的方法定义了的服务协定，就是说用ServiceContract属性修饰了一个类而不是一个接口。    <br />无论如何，我们要开始做一点儿实现了。第一件事儿是设定ServiceContract属性的NameSpace参数。这一点非常重要。客户端用于调用WCF服务的代理的名字空间就是从这里拿的。我就将名字空间设为urn:shopping/services.[ServiceContract(Namespace = &quot;urn:shopping/services&quot;)]    <br />接下来，我要添加一个操作（就是一个用OperationContract修饰的方法）。这个操作使用LINQ to SQL到数据库获取一页产品信息。该实现返回一个包含ProductData类型的ProductGroupingData 类型。我这样做的原因在于我不仅需要返回产品信息（ProductData），还需要一些有助于分页的元数据（StartIndex， PageSizebut 和ProductGrouping的TotalCount）。 下面就是这些类型:    <br />[DataContract]    <br />public class ProductData    <br />{    <br />[DataMember]    <br />public int ProductId;    <br />[DataMember]    <br />public string ProductName;    <br />[DataMember]    <br />public string Description;    <br />[DataMember]    <br />public decimal Price;    <br />[DataMember]    <br />public string ProductImage;    <br />}    <br />[DataContract]    <br />public class ProductGroupingData    <br />{    <br />[DataMember]    <br />public List&lt;ProductData&gt; Products;    <br />[DataMember]    <br />public int StartIndex;    <br />[DataMember]    <br />public int PageSize;    <br />[DataMember]    <br />public int TotalCount = 0;    <br />}    <br />以下是实现代码：    <br />[OperationContract]    <br />public ProductGroupingData GetProductGrouping(int startIndex, int pageSize)    <br />{    <br />using (CatalogDataContext catalogCtx = new CatalogDataContext())    <br />{    <br />// Set up the query    <br />var products = from p in catalogCtx.Products    <br />orderby p.ProductName    <br />select new ProductData()    <br />{    <br />ProductId = p.ProductId,    <br />ProductName = p.ProductName,    <br />Description = p.ProductDescription,    <br />Price = p.Price,    <br />ProductImage = p.ProductImage    <br />};    <br />// Use skip and take extension methods for server side paging&#160; <br />// and call ToList to execute the query    <br />var productColl = products.Skip(startIndex).Take(pageSize).ToList();    <br />// Add the metadata&#160; <br />var package = new ProductGroupingData()    <br />{    <br />Products = productColl,    <br />StartIndex = startIndex,    <br />PageSize = pageSize,    <br />TotalCount = catalogCtx.Products.Count()    <br />};    <br />return package;</p>  <p>}   <br />到这里，我们已经创建好了一个支持AJAX的服务。一个服务支持AJAX，就是说该服务可以非常容易地被一个 AJAX 客户端调用。接下来的 WCF中的REST架构 三，我就讨论如何在客户端调用服务.</p>]]></content:encoded>
    </item>
    <item>
      <title>WCF中的REST架构一（REST 概述）</title>
      <link>https://docs.microsoft.com/archive/blogs/wcftoolsteamblogcn/wcfrestrest</link>
      <pubDate>Mon, 12 Jan 2009 03:20:31 GMT</pubDate>
      <dc:creator><![CDATA[Minmin Xue]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wcftoolsteamblogcn/2009/01/12/wcfrestrest/</guid>
      <description><![CDATA[注：从今天开始，我们将陆续翻译Rob Bagby的精彩文章&quot;REST in WCF&quot;...]]></description>
      <content:encoded><![CDATA[<p><em> 注：从今天开始，我们将陆续翻译Rob Bagby的精彩文章&quot;REST in WCF&quot; 系列，原文链接如下：</em><a href="https://blogs.msdn.com/bags/archive/2008/05/28/rest-in-wcf-part-i-rest-overview.aspx">https://blogs.msdn.com/bags/archive/2008/05/28/rest-in-wcf-part-i-rest-overview.aspx</a></p>  <p>WCF中的 REST架构一（REST 概述）</p>  <p>不同的人似乎对REST有不同的定义，有些定义是非常严格的，而有些则是比较自由的。我倾向于认为REST架构存在于一个连续的范围里， 如图所示：</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTREST_E5C1/image_2.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTREST_E5C1/image_2.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="163" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTREST_E5C1/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/wcftoolsteamblogcn/WindowsLiveWriter/WCFRESTREST_E5C1/image_thumb.png" width="632" border="0" /></a> </p>  <p>我们可以认为REST背后隐含的基本理念如下：</p>  <p>· 越简单越好</p>  <p>· Web一直是非常成功的。</p>  <p>· Web是很简单的。</p>  <p>· Web设计要遵循一些指导性原则，而这些原则在过去很长一段时间内都是可靠的。</p>  <p>· Web 服务的设计要以 Web的方式。</p>  <p>尽管不同的人对 REST有不同的定义，但可以肯定的是存在一些特征来影响一个服务是否是RESTful的，或者它能不能被认为是RESTful, 或者它能否落在上面这个连续范围内的某个位置。这里列出一些（并不是全部）特征：</p>  <p>· 对HTTP 方法(GET,PUT,POST,DELETE是主要的HTTP方法)的合理使用——HI-REST端倾向于对具体方法用于具体的情景进行严格的规定。例如一个HI-REST的实现中使用GET方法获取，DELETE方法用来删除，PUT方法用来插入或者更新，而POST方法则用来附加。而LO-REST的解决方案则可能使用POST方法做插入，更新，删除和附加操作。</p>  <p>· 对数据表现形式的选择——HI-REST解决方案倾向于选择标准的数据表现形式，而一些LO-REST解决方案则认为POX也是一个不错的选择。</p>  <p>· 对良好构造的URI的使用——HI-REST解决方案倾向于使用描述性的URI而一般情况下不使用查询字符串，而我们在一些LO-REST解决方案中可以看到对查询字符串的使用。</p>  <p>· 其他：有效负荷中包含指向相关信息的链接，使用合适的HTTP 响应代码。</p>  <p>我没有在什么是REST的基础上给出一个严格的定义，原因并不是我觉得这不重要。原因是，从WCF的角度，一个专门的定义无关紧要。WCF支持范围两端的REST架构（HI-REST和LO-REST）。事实上，在下一篇文章中，我将建立一个LO-REST的实现，同时在之后的文章中，我将演示HI-REST端的实现。</p>  <p>如果上面这些对你来说都没有什么意义，也没有关系，下面的文章将提供具体的实例。</p>]]></content:encoded>
    </item>
  </channel>
</rss>