WCF 安全机制 客户端和服务端配置文件

wsHttpBinding 客户端和服务端配置文件

客户端:wsHttpBinding


[html]  view plain copy print ?
  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <configuration>  
  3.   <system.serviceModel>  
  4.     <bindings>  
  5.   
  6.       <wsHttpBinding>  
  7.         <binding name="ServiceBinding"  maxReceivedMessageSize="1073741824"  receiveTimeout="00:05:00"  sendTimeout="00:05:00">  
  8.           <security mode="None">  
  9.             <transport clientCredentialType="None"/>  
  10.           </security>  
  11.           <readerQuotas maxStringContentLength ="1073741824" maxArrayLength ="1073741824" />  
  12.         </binding>  
  13.       </wsHttpBinding>  
  14.         
  15.     </bindings>  
  16.     <client>  
  17.       <!--iis host for run-->  
  18.       <endpoint address="http://localhost:4906/test.svc"  
  19.                   binding="wsHttpBinding"  
  20.                   bindingConfiguration="ServiceBinding"  
  21.                   contract="Contract.IMyTest"  
  22.                             name="TestEndpoint" />  
  23.     </client>  
  24.   </system.serviceModel>  
  25. </configuration>  



服务器


[html]  view plain copy print ?
  1. <?xml version="1.0"?>  
  2. <configuration>  
  3.   <configSections>  
  4.     <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">  
  5.       <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">  
  6.         <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
  7.         <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">  
  8.           <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>  
  9.           <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
  10.           <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
  11.           <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
  12.         </sectionGroup>  
  13.       </sectionGroup>  
  14.     </sectionGroup>  
  15.   </configSections>  
  16.   <appSettings/>  
  17.   <connectionStrings/>  
  18.   <system.web>  
  19.     <!--   
  20.             设置 compilation debug="true" 可将调试符号插入  
  21.             已编译的页面中。但由于这会   
  22.             影响性能,因此只在开发过程中将此值   
  23.             设置为 true。  
  24.         -->  
  25.     <compilation debug="true">  
  26.       <assemblies>  
  27.         <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
  28.         <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
  29.         <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  30.         <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
  31.       </assemblies>  
  32.     </compilation>  
  33.     <!--  
  34.             通过 <authentication> 节可以配置 ASP.NET 用来   
  35.             识别进入用户的  
  36.             安全身份验证模式。   
  37.         -->  
  38.     <authentication mode="Windows"/>  
  39.     <!--  
  40.             如果在执行请求的过程中出现未处理的错误,  
  41.             则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,  
  42.             开发人员通过该节可以配置  
  43.             要显示的 html 错误页  
  44.             以代替错误堆栈跟踪。  
  45.   
  46.         <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">  
  47.             <error statusCode="403" redirect="NoAccess.htm" />  
  48.             <error statusCode="404" redirect="FileNotFound.htm" />  
  49.         </customErrors>  
  50.         -->  
  51.     <pages>  
  52.       <controls>  
  53.         <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  54.         <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  55.       </controls>  
  56.     </pages>  
  57.     <httpHandlers>  
  58.       <remove verb="*" path="*.asmx"/>  
  59.       <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  60.       <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  61.       <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>  
  62.     </httpHandlers>  
  63.     <httpModules>  
  64.       <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  65.     </httpModules>  
  66.   </system.web>  
  67.   <system.codedom>  
  68.     <compilers>  
  69.       <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">  
  70.         <providerOption name="CompilerVersion" value="v3.5"/>  
  71.         <providerOption name="WarnAsError" value="false"/>  
  72.       </compiler>  
  73.     </compilers>  
  74.   </system.codedom>  
  75.   <!--   
  76.         在 Internet 信息服务 7.0 下运行 ASP.NET AJAX 需要 system.webServer  
  77.         节。对早期版本的 IIS 来说则不需要此节。  
  78.     -->  
  79.   <system.webServer>  
  80.     <validation validateIntegratedModeConfiguration="false"/>  
  81.     <modules>  
  82.       <remove name="ScriptModule"/>  
  83.       <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  84.     </modules>  
  85.     <handlers>  
  86.       <remove name="WebServiceHandlerFactory-Integrated"/>  
  87.       <remove name="ScriptHandlerFactory"/>  
  88.       <remove name="ScriptHandlerFactoryAppServices"/>  
  89.       <remove name="ScriptResource"/>  
  90.       <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  91.       <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  92.       <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
  93.     </handlers>  
  94.   </system.webServer>  
  95.   <runtime>  
  96.     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
  97.       <dependentAssembly>  
  98.         <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>  
  99.         <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>  
  100.       </dependentAssembly>  
  101.       <dependentAssembly>  
  102.         <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>  
  103.         <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>  
  104.       </dependentAssembly>  
  105.     </assemblyBinding>  
  106.   </runtime>  
  107.   <system.serviceModel>  
  108.     <services>  
  109.       <service name="Service.SMyTest" behaviorConfiguration="ServiceBehavior">  
  110.         <host>  
  111.           <!--注意了-->  
  112.           <!--必须要有基地址 net.tcp,如果没有net基地址就不能有 http 基地址,否则报错-->  
  113.           <!--添加 http 基地址是为了方便调试,可在浏览器中浏览,也可获得元数据 【httpGetEnabled 必须为 true】-->  
  114.           <!--注意了-->  
  115.           <!--必须和 behaviorConfiguration 的属性 HttpGetEnable 配合使用-->  
  116.           <!--baseAddress 调试环境下可以根据情况设置-->  
  117.           <baseAddresses>  
  118.           </baseAddresses>  
  119.         </host>  
  120.         <!--终结点配置-->  
  121.         <!--address:服务地址 | binding:绑定类型(通信方式) | bindingConfiguration:服务终结点绑定配置名称 | contract:契约【即:命名空间.服务契约(服务接口)】-->  
  122.         <!--address, 根据生产环境实际情况设置-->  
  123.         <!--contract 根据不同应用程序设置-->  
  124.         <!--<endpoint address="" binding="netTcpBinding" bindingConfiguration="ServiceBinding" contract="Contract.IMyTest"/>-->  
  125.         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>  
  126.         <endpoint address="" binding="wsHttpBinding" bindingConfiguration="ServiceBinding" contract="Contract.IMyTest"/>  
  127.       </service>  
  128.     </services>  
  129.     <behaviors>  
  130.       <serviceBehaviors>  
  131.         <behavior name="ServiceBehavior">  
  132.           <serviceMetadata httpGetEnabled="true"/>  
  133.           <serviceDebug includeExceptionDetailInFaults="True"/>  
  134.           <!-- 配置运行时吞吐量设置,这些设置可以优化服务性能-->  
  135.           <!-- maxConcurrentCalls:该值指定整个 ServiceHost 中正在处理的最多消息数-->  
  136.           <!-- maxConcurrentInstances:获取或设置一个值,该值指定服务中可以一次执行的最多 InstanceContext 对象数-->  
  137.           <!-- maxConcurrentSessions:获取或设置一个指定 ServiceHost 对象可一次接受的最多会话数的值-->  
  138.           <serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="1000"/>  
  139.         </behavior>  
  140.       </serviceBehaviors>  
  141.     </behaviors>  
  142.     <bindings>  
  143.       <wsHttpBinding>  
  144.         <binding name="ServiceBinding" receiveTimeout="00:10:00" sendTimeout ="00:10:00" maxReceivedMessageSize="999999"  >  
  145.           <readerQuotas maxStringContentLength="30000"  />  
  146.           <security mode="None"></security>  
  147.         </binding>  
  148.       </wsHttpBinding>  
  149.         
  150.     </bindings>  
  151.   </system.serviceModel>  
  152. </configuration>  
ws2007HttpBinding 客户端和服务端配置文件

ws2007HttpBinding  客户端



  <system.serviceModel>
    <bindings>
      <ws2007HttpBinding>
        <binding name="WS2007HttpBinding_ICenterDynamicService"  maxReceivedMessageSize="2147483647" >
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"  maxNameTableCharCount="2147483647" />
          <security mode="Message">
            <transport clientCredentialType="Windows" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </ws2007HttpBinding>
    </bindings>
    <client>
      <endpoint address="http://xxxxxxx.com/Services/Activity/CenterDynamicService.svc"
        binding="ws2007HttpBinding" bindingConfiguration="WS2007HttpBinding_ICenterDynamicService"
        contract="DBCenterDynamicService.ICenterDynamicService" name="WS2007HttpBinding_ICenterDynamicService">
        <identity>
          <servicePrincipalName value="host/iZ23joewgpoZ" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>


ws2007HttpBinding  服务器端



  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ESBAPIServiceI" />
      </basicHttpBinding>
      <ws2007HttpBinding>
          <binding name="ws2007HttpBindingServiceBinding" receiveTimeout="00:10:00" sendTimeout ="00:10:00"   maxReceivedMessageSize='2147483647'   >
          <readerQuotas maxDepth='2147483647'
                        maxStringContentLength='2147483647'
                         maxArrayLength='2147483647'
                         maxBytesPerRead='2147483647'
                         maxNameTableCharCount='2147483647'/>
          </binding>  
      </ws2007HttpBinding>

    </bindings>
    <client>
      <endpoint address="http://xxxxxxxx1/Server/ESBAPIService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ESBAPIServiceI"
        contract="ESBAPIService.ESBAPIServiceI" name="BasicHttpBinding_ESBAPIServiceI" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>


        <behavior  name="useWindowsGroupsAuthorization">
          <serviceAuthorization principalPermissionMode="UseWindowsGroups"/>
          <serviceMetadata httpGetEnabled="true" />
        </behavior>



      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />


    <services>
      <service name="DBServices.Services.Activity.CenterDynamicService" behaviorConfiguration="useWindowsGroupsAuthorization">
        <endpoint address="" binding="ws2007HttpBinding"  bindingConfiguration="ws2007HttpBindingServiceBinding" contract="DBServices.Services.Activity.ICenterDynamicService"/>
      </service>
    </services>





  </system.serviceModel>





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值