Sun_Blue_Sky

菩提本无树,明镜亦非台,本来无一物,何处惹尘埃 寻求内心的平静
随笔 - 21, 文章 - 92, 评论 - 75, 阅读 - 10万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

WCF一个Web Application多个服务

Posted on   Sun_Blue_Sky  阅读(424)  评论(0编辑  收藏  举报

本章说明:

实际开发中可能出现多种不同类型的服务,放在一起这是不合理的,我认为可以考虑在同一个Web Application中绑定多个Service。

 

复制代码
Server Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingConfiguration" maxReceivedMessageSize="2147483647">
          <security mode="None">
          </security>
        </binding>
      </wsHttpBinding>
      <basicHttpBinding>
        <binding name="basicHttpBindingConfiguration" maxReceivedMessageSize="2147483647">
          <security mode="None">
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behaviorConfiguration">
          <serviceDebug includeExceptionDetailInFaults="true"  />
          <serviceMetadata httpGetBinding="webHttpBinding" httpGetBindingConfiguration="" httpGetEnabled="true" />
          <serviceThrottling maxConcurrentSessions="10000"  maxConcurrentInstances="10000" maxConcurrentCalls="10000" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="behaviorConfiguration" name="WcfServer.RoleService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration" contract="WcfServer.IRoleService" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="behaviorConfiguration" name="WcfServer.UserService" >
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration" contract="WcfServer.IUserService" />
        <endpoint address="soap11" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration"  contract="WcfServer.IUserService" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
复制代码
复制代码
Client Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingConfiguration" >
          <security mode="None">
          </security>
        </binding>
      </wsHttpBinding>
      <basicHttpBinding>
        <binding name="basicHttpBindingConfiguration">
          <security mode="None">
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/WcfServer/RoleService.svc"
     binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration"
     contract="WcfServer.IRoleService" name="RoleService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="http://localhost/WcfServer/UserService.svc"
        binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration"
        contract="WcfServer.IUserService" name="UserService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="http://localhost/WcfServer/UserService.svc/Soap11"
        binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration"
        contract="WcfServer.IUserService" name="UserServiceSoap11">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>
复制代码

 

编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示