我已經創建了一個工作的WCF服務。我現在想爲它添加一些安全性來過濾IP地址。我遵循微軟在示例中發佈的示例來嘗試添加一個IDispatchMessageInspector,它將引發一個調用AfterReceiveRequest,然後在ip地址不是來自允許列表的情況下拋出一個錯誤。爲什麼我的WCF服務提供消息「沒有與無消息版本的綁定」?
查看代碼後;他們使用'wsHttpBinding'來配置它,但是我想使用'webHttpBinding'或'basicHttpBinding'。但是,當我把它我得到的錯誤:
The endpoint at 'http://upload/api/Api.svc/soap' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.WebHttpBehavior' is only intended for use with WebHttpBinding or similar bindings.
我的配置是:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<!--Set up the service-->
<services>
<service behaviorConfiguration="SOAPRESTDemoBehavior" name="HmlApi">
<endpoint address="rest" binding="webHttpBinding" contract="VLSCore2.Interfaces.IHmlApi" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" />
<endpoint address="soap" binding="basicHttpBinding" contract="VLSCore2.Interfaces.IHmlApi" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" />
</service>
</services>
<!--Define the behaviours-->
<behaviors>
<serviceBehaviors>
<behavior name="SOAPRESTDemoBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<!---Endpoint -->
<endpointBehaviors>
<behavior name="SOAPRESTDemoEndpointBehavior">
<ipFilter/>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="ipFilter" type="VLSCore2.Api.IpFilterBehaviourExtensionElement, VLSCore2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
所以即時知道什麼是我該怎麼設置我的消息檢查不使用的WebHttpBinding。這甚至有可能嗎?
我想使用SOAP「basicHttpBinding的」不WsHttpBinding的(和所有的WS *)的相關費用....
非常感謝這點上。公平地說,我認爲現在爲服務建立所有正確的端點是重要的! – Exitos
男人,我已經掙扎了幾個小時了,我到了這裏注意到我沒有改變綁定:)))我使用基本的移動應用程序的HTTP請求...大拇指+ – dpaul1994