我已经创建了一个有效的WCF服务.我现在想为它添加一些安全性来过滤Ip地址.我已经按照示例中的microsoft发布样本来尝试添加IDispatchMessageInspector,它将引发调用AfterReceiveRequest,然后如果ip地址不是来自允许列表则抛出错误.
看完代码后; 他们使用'wsHttpBinding'配置它,但我想使用'webHttpBinding'或'basicHttpBinding'.但是当我设置它时,我得到错误:
'http://upload/api/Api.svc/soap'中的端点没有与None MessageVersion的绑定.'System.ServiceModel.Description.WebHttpBehavior'仅适用于WebHttpBinding或类似绑定.
我的配置是:
<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>
Run Code Online (Sandbox Code Playgroud)
所以我想知道如何在不使用WebHttpBinding的情况下设置我的消息检查器.这甚至可能吗?
我想使用SOAP'basicHttpBinding'而不是wsHttpBinding(以及所有WS*)相关的开销....