.net RESTful WCF 服务在 POST 操作中返回“找不到端点”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/650864/
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
RESTful WCF service returns "endpoint not found" error on POST operations
提问by joshua.ewer
I've built a WCF service that's exposed both through SOAP and RESTfully. All SOAP actions work as advertised. GETS/PUTS do as well, but when I try to do a POST to an action in my service, I get the following error returned:
我已经构建了一个通过 SOAP 和 RESTful 公开的 WCF 服务。所有 SOAP 操作都按照宣传的方式工作。GETS/PUTS 也可以,但是当我尝试对服务中的某个操作执行 POST 时,返回以下错误:
"Endpoint not found"
“未找到端点”
IPersonEditServiceContract snippet:
IPersonEditServiceContract 片段:
[OperationContract]
[WebInvoke(Method="POST",
UriTemplate="/persons",
RequestFormat=WebMessageFormat.Xml,
ResponseFormat=WebMessageFormat.Xml)]
SavePersonResponse SavePerson(SavePersonRequest request);
[OperationContract]
WebGet(UriTemplate = "/persons/{personId}",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Xml)]
Person GetClaimantById(string personId);
Service is configured this way:
服务是这样配置的:
<behaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service>
<endpoint address="" binding="basicHttpBinding"
name="DefaultEndpoint"
bindingNamespace="http://mycompany.com/ServiceContracts"
contract="IPersonEditServiceContract" />
<endpoint
address="rest" binding="webHttpBinding"
name="RESTEndpoint"
bindingNamespace="http://mycompany.com/ServiceContracts"
contract="IPersonEditServiceContract"
behaviorConfiguration="restBehavior"/>
</service>
</services>
Since I can do other RESTful operations against the same endpoint, I'm not entirely sure why it gives me that semi-helpful error.
因为我可以对同一个端点执行其他 RESTful 操作,所以我不完全确定为什么它会给我这个半有用的错误。
Ideas?
想法?

