[英]RESTful WCF service returns “endpoint not found” error on POST operations
我已經構建了一個 WCF 服務,該服務通過 SOAP 和 RESTfully 公開。 所有 SOAP 操作都像宣傳的那樣工作。 GETS/PUTS 也可以,但是當我嘗試對我的服務中的操作執行 POST 時,會返回以下錯誤:
“未找到端點”
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);
服務是這樣配置的:
<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>
因為我可以對同一個端點執行其他 RESTful 操作,所以我不完全確定它為什么會給我這個半有用的錯誤。
想法?
我認為 WCF 給出了錯誤,因為它真的找不到端點。 您是否使用 POST 到 /rest 下的右側 URL 來擊中它? 嘗試Fiddler創建 POST 調用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.