zoukankan      html  css  js  c++  java
  • 2 WCF里面配置的含义

    1 首先介绍所谓的a,b,c。

    a就是address 地址;

    b binding 绑定的协议 譬如http  tcp udp 利用这些协议方式请求address;

    c contract  代表请求的规则 要请求的方法 譬如 getData()

    2 附上一张wcf 根据配置通信的抽象简图

     3 附上一张wcf服务端配置文件的节点结构图

    4 代码说明

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- 部署服务库项目时,必须将配置文件的内容添加到
     主机的 app.config 文件中。System.Configuration 不支持库的配置文件。 -->
      <!--*******************************************************system.serviceModel WCF配置部分****************************************************************-->
      <system.serviceModel>
        <!--******************Services节点****************-->
        <!--说明 在生成的默认配置文件中 Services节点只有services和behaviors两个子节点,如果要加bindings节点 这个节点也要作为Services的子节点-->
        <!--这个binding限制了协议的超时时间 所以说这个节点可以用来配置好 让 endpoint里面的 b调用-->
        <bindings>
          <basicHttpBinding>
            <binding name="myBasicHttpBinding" openTimeout="00:30:00" sendTimeout="00:30:00">
              <security mode="None"/><!--设置没有安全性-->
            </binding>
          </basicHttpBinding>
        </bindings>
        
        <services>
          <service name="ServiceLib.Service1">
            <host>
              <baseAddresses>
                <!--<add baseAddress = "http://localhost:8733/Design_Time_Addresses/ServiceLib/Service1/" />被注释的原代码-->
                <!--这是address的基地址-->
                <add baseAddress = "http://localhost:8733/Service" /><!--这段代码是对上面一行的修改-->
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- 除非完全限定,否则地址相对于上面提供的基址-->
            <!--这就是本文第二部分的endpoint  它由本文第一部分的abc组成-->
            <!--address在这里默认为空 真是的地址等于baseAdress+address-->
            <!--basicHttpBinding http协议 contract指定了契约-->
            <endpoint address="" binding="basicHttpBinding"
                      contract="ServiceLib.IService1" 
                      bindingConfiguration="myBasicHttpBinding"><!--此处利用了上面的bindings节点-->
              <!-- 
                  部署时,应删除或替换下列标识元素,以反映
                 用来运行所部署服务的标识。删除之后,WCF 将
                  自动推断相应标识。
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- 元数据交换终结点供相应的服务用于向客户端做自我介绍。 --> 
            <!-- 此终结点不使用安全绑定,应在部署前确保其安全或将其删除-->
            <!--通过这个endpoint像客户端公布服务端的信息 契约是IMetadataExchange-->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <!--******************Services节点****************-->
        <!--******************behaviors节点****************-->
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- 为避免泄漏元数据信息,
              请在部署前将以下值设置为 false -->
              <!--设置成false 在请求http://localhost:8733/Service 的时候 不能请求http网页的元数据展示-->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <!-- 要接收故障异常详细信息以进行调试,
              请将以下值设置为 true。在部署前设置为 false 
              以避免泄漏异常信息 -->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <!--******************behaviors节点****************-->
      </system.serviceModel>
      <!--*******************************************************system.serviceModel WCF配置部分****************************************************************-->
    </configuration>
  • 相关阅读:
    ajax_基础1
    省市数据库脚本TblArea.
    c#中怎么使用dos命
    Lambda表达式
    面试收录
    .Net牛逼程序猿要懂得
    Web.config 配置文件
    sql 查询所有数据库、表名、表字段总结
    Json在net与页面之间的传递
    『转』SAP统驭科目解释
  • 原文地址:https://www.cnblogs.com/wholeworld/p/10068379.html
Copyright © 2011-2022 走看看