zoukankan      html  css  js  c++  java
  • WCF使用net.tcp绑定时的注意事项

    IIS Express没有net.tcp绑定功能,本地测试的话只能使用本机的IIS进行承载,并且需要相应的配置(参见上一篇文章)。

    算了,直接举一个配置例子吧,懒得写了。。。

    <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <!--默认http绑定的配置,这里提高了最大传输信息的大小,如不需要可以不设置绑定配置-->
            <binding name="DefaultBasicHttpBinding"  maxBufferSize="10485760" maxReceivedMessageSize="10485760" />
          </basicHttpBinding>
          <netTcpBinding>
            <!--默认net.tcp绑定的配置,貌似必须要对net.tcp方式绑定进行配置-->
            <binding name="DefaultNetTcpBinding" portSharingEnabled="true" transferMode="Buffered">
              <security mode="None" />
            </binding>
          </netTcpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service name="WcfTest.DataService">
            <!-- endpoint 的 address 属性:
                  1、使用绝对路径(网址);
                  2、如果使用相对路径(网址),则将根据 host 的 baseAddress 确定最终路径(网址)。 -->
            
            <!--http绑定方式-->
            <endpoint address="" binding="basicHttpBinding" contract="WcfTest.IDataService" bindingConfiguration="DefaultBasicHttpBinding" />
            <!--net.tcp绑定方式-->
            <endpoint address=""  binding="netTcpBinding" contract="WcfTest.IDataService" bindingConfiguration="DefaultNetTcpBinding" />
    
            <!-- 元数据交换(mex)终结点供相应的服务用于向客户端做自我介绍。此终结点不使用安全绑定,应在部署前确保其安全或将其删除 -->
            
            <!--为http绑定提供元数据-->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <!--为net.tcp绑定提供元数据-->
            <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
            
            <!--承载WCF服务的基地址。
                注:当使用ASP.NET网站承载WCF服务时,网站需要使用svc文件进行承载服务,此时基地址将变成svc文件的地址。
            -->
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost/Design_Time_Addresses/DataService/" />
              </baseAddresses>
            </host>
          </service>
        </services>
      </system.serviceModel>
  • 相关阅读:
    js四舍五入
    文本框只能输入整数,输入其他的自动不显示
    [转]关于C#程序部署到Android
    ajax在火狐中传中文出现乱码的解决方法
    Vue 记录 Cannot read property '_withTask' of undefined
    vs中 VMDebugger未能加载导致异常
    System.InvalidOperationException: 支持“XXX”上下文的模型已在数据库创建后发生更改。请考虑使用 Code First 迁移更新数据库(http://go.microsoft.com/fwlink/?LinkId=238269)。
    eclipse中将java项目转换成javaweb项目
    Android之SOAP协议与WebService服务器交互,解决超时的问题
    SymmetricDS 快速和灵活的数据库复制
  • 原文地址:https://www.cnblogs.com/xwgli/p/3838050.html
Copyright © 2011-2022 走看看