C# EndpointDispatcher 处的 ContractFilter 不匹配?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15244414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 14:37:08 来源:igfitidea点击:
ContractFilter mismatch at the EndpointDispatcher?
提问by bala3569
Here i am calling the method from the hosted RESTful service in my browser
在这里,我从浏览器中托管的 RESTful 服务调用该方法
https://eshop/LinkService/LinkService.svc/GetStudentObj
and getting the following error
并收到以下错误
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)
Config file
配置文件
<system.serviceModel>
<services>
<service name="LinkService.LinkService" behaviorConfiguration="MyServiceBehavior">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="https" contract="LinkService.ILinkService" />
<endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="https">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
and
和
public Student GetStudent()
{
Student stdObj = new Student
{
StudentName = "Bala",
Age = 29,
Mark = 95
};
return stdObj;
}
and
和
[ServiceContract]
public interface ILinkService
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetStudentObj", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json)]
Student GetStudent();
}
Any suggestion?
有什么建议吗?
采纳答案by kk1076
Add behaviour configuration in <endpoint address />
tag
在<endpoint address />
标签中添加行为配置
<endpoint address="" binding="webHttpBinding" bindingConfiguration="https" contract="LinkService.ILinkService" behaviorConfiguration="web"/>