问题
I have a REST WCF service. When a POST attempt is made to this service to an operation as mentioned below, I get the below error:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "", RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
void Write();
Error: HTTP 307 There is no operation listening for https://xx.xxx.xx.xxx/EnrollmentServer/Discovery.svc, but there is an operation listening for https://xx.xxx.xx.xxx/EnrollmentServer/Discovery.svc/, so you are being redirected there.
Any pointers will be appreciated.
回答1:
Change your UriTemplate to "/" instead. RESTful WCF has a "thing" about wanting Uris ending with / instead of no ending.
Also, use the Uri with the ending slash to avoid WCF responding with the 307.
来源:https://stackoverflow.com/questions/14358178/wcf-rest-error-http-307