使用wsHttpBinding, WCF忽略我的web.config
本文关键字:我的 web config wsHttpBinding WCF 使用 | 更新日期: 2023-09-27 18:07:51
我正在尝试创建一个需要会话支持的WCF服务,所以我在我的web中添加了一个部分。配置以启用wsHttpBinding。但是当我在WCF测试客户端中测试服务并检查配置时,它似乎采用了默认的自动生成配置,而不是我自己的配置。
查看我的config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="UserService">
<endpoint address="" binding="wsHttpBinding" contract="ICenterPlaceUserService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
和结果:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICenterPlaceUserService" sendTimeout="00:05:00" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:57418/L1.WCF/CenterPlaceUserService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICenterPlaceUserService"
contract="ICenterPlaceUserService" name="BasicHttpBinding_ICenterPlaceUserService" />
</client>
</system.serviceModel>
我错过了什么
<service>
属性中的name
属性必须具有服务分类的全限定名。否则它将被忽略,你将看到你所看到的行为:默认绑定被用于服务(basicHttpBinding)。
<services>
<service name="TheNamespaceOfYourClass.UserService">
<endpoint address=""
binding="wsHttpBinding"
contract="TheNamespaceOfYourContract.ICenterPlaceUserService" />
</service>
</services>