我想創建一個需要會話支持的WCF服務,所以我在web.config中添加了一個部分來啓用wsHttpBinding。但是當我在WCF測試客戶端測試服務並檢查配置時,它似乎採用了默認的自動生成的配置而不是我自己的配置。使用wsHttpBinding,WCF忽略我的web.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>
我錯過了什麼?
我假設您正在爲您的項目添加服務引用。如果這是真的,那麼你之後是否更新了項目中的服務參考? – Justin 2013-04-07 23:18:27
到目前爲止,我沒有在任何項目中使用該服務。我使用的WCF測試客戶端,當我從* .svc.cs文件中按下調試時會自動打開。 – 2013-04-07 23:21:14
您是否嘗試保存該項目,關閉Visual Studio並重試? – Justin 2013-04-07 23:27:02