沒有工作,我有一個WCF服務:綁定在 「雙模」(的WebHttpBinding和basicHttpBinding的)
<%@ ServiceHost Language="C#" Debug="true" Service="IWW.MIGTurbo2.WCF.Security.SecurityBroker" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
這正常使用的WebHttpBinding從我的web項目。
我也希望這個服務可以被WinForms客戶端使用,所以添加了一個basicHttpBinding綁定。
我的服務器配置文件是當前:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="webScriptEnablingBehavior">
<enableWebScript />
</behavior>
<behavior name="webHttpEnablingBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="webHttpEnablingBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="webScriptEnablingBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="IWW.MIGTurbo2.WCF.Security.SecurityBroker" behaviorConfiguration="webHttpEnablingBehaviour">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<!-- This works for web-clients -->
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="default"
contract="IWW.MIGTurbo2.WCF.Security.ISecurityBroker"
behaviorConfiguration="webHttpEnablingBehaviour">
</endpoint>
<!-- This is for WinForms clients, but isn't working -->
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="default"
contract="IWW.MIGTurbo2.WCF.Security.ISecurityBroker"
behaviorConfiguration="webHttpEnablingBehaviour">
</endpoint>
</service>
</services>
<client />
<bindings>
<webHttpBinding>
<binding name="default" ></binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="default" allowCookies="true"></binding>
</basicHttpBinding>
</bindings>
標記爲的WinForms的部分不會出現工作。我收到一個異常:
The endpoint at ' http://localhost:56125/MIGTurbo2_WEB/api/wcf/SecurityBroker.svc ' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.WebHttpBehavior' is only intended for use with WebHttpBinding or similar bindings.
當我嘗試使用IE手動瀏覽到.svc文件時。顯然,WinForms客戶端不想知道。
任何人都可以傳播爲什麼它不工作?它幾乎看起來好像我不能有多個端點或第二個端點配置不正確? Google沒有提供任何特別有用的東西。
該服務如何託管?我注意到兩個端點都沒有配置地址,在您提供的示例中沒有定義基地址。另外,爲什麼你的winforms應用程序不能使用webHttpBinding? – 2009-05-18 13:15:57
該服務託管在網站項目的「api」文件夾下。這是目前在ASP.NET開發服務器後面,但最終會落後於IIS。 我還沒有指定任何地址,因爲我不想在此時綁定到任何固定主機。該項目應該可以部署到各種URL,並且不希望如果可能的話將其綁定。 (我正在使用代碼生成URL) – 2009-05-18 13:46:17