Bri*_*ian 1 .net c# wcf windows-services wcf-binding
The endpoint at 'http://localhost:8731/Design_Time_Addresses/WCF/WCFService/' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.WebHttpBehavior' is only intended for use with WebHttpBinding or similar bindings.
Run Code Online (Sandbox Code Playgroud)
这是我尝试启动WCF服务时遇到的错误.我在这里阅读了关于绑定错误的每篇文章,但它们都有点不同,我无法弄明白.这是我的app.config:
<system.serviceModel>
<services>
<service name="WCF.WCFService">
<endpoint address="" binding="wsHttpBinding" contract="WCF.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我在Windows服务中托管我的WCF服务,如果这有所不同.MY End的目标是使用winforms应用程序来使用WCF服务.当我在VS中运行WCF服务时,它可以工作,但是当我将配置添加到windows服务app.config并尝试用它启动WCF服务时,我收到错误.任何帮助都会很棒.
Chr*_*ers 11
该异常通知您端点行为与绑定不兼容(wsHttpBinding).
从端点行为中删除<webHttp />或使用WebHttpBinding而不是wsHttpBinding.
如果要为使用HTTP请求而不是SOAP消息的Web服务配置端点,请使用WebHttpBinding.WebHttpBehavior(<webHttp />)在与WebHttpBinding(或兼容的)一起使用时启用此编程模型.
这就是问题所在.此行为与您选择的绑定(wsHttpBinding)无法兼容.
您还应该命名端点配置:
<endpointBehaviors>
<behavior name="WebHttp">
<webHttp />
</behavior>
</endpointBehaviors>
Run Code Online (Sandbox Code Playgroud)
并使用名称将其链接到服务的端点:
<endpoint address="" binding="wsHttpBinding" contract="WCF.IWCFService"
behaviorConfiguration="WebHttp"/>
<identity>
<dns value="localhost" />
</identity>
</endpoint>
Run Code Online (Sandbox Code Playgroud)
这可确保您的服务端点使用WebHttp端点行为(webHttp)指定的行为.现在你没有给它命名,所以mex端点也会出现这种情况.这不是必需的.只需将mexHttpBinding用于mex端点,但不要将其链接到与服务相同的行为.