0
我已經通過這個挖近兩天,這表明它的將是一個非常簡單的解決辦法:我應該到什麼地方:WCF休息 - POST端點未找到
我有一個WCF REST服務。 GET很適合返回JSON,但是在POST中,我只收到在Chrome和Fiddler中找不到的Endpoint。
我將提供GET和POST屬性,以防萬一我通過GET方法做了一些事情。
<services>
<service name="WCFServiceWebRole1.Class" behaviorConfiguration="serviceBehavior">
<endpoint address=""
binding="webHttpBinding"
contract="WCFServiceWebRole1.IClass"
behaviorConfiguration="web">
</endpoint>
</service>
<service name="WCFServiceWebRole1.ClassPost" behaviorConfiguration="serviceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="WCFServiceWebRole1.IClassPost"
behaviorConfiguration="web">
</endpoint>
</service>
</services>
有一件事對我來說很重要,那就是沒有爲GET設置。通過改變它,我打破了GET的解決方案,但是通過從POST中刪除它不會改變這種情況。然後
我的服務合同,看起來像這樣:
[ServiceContract]
public interface IClass
{
[WebInvoke(ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/GET/?json={jsonString}", Method = "GET")]
string Decode(string jsonString);
// TODO: Add your service operations here
}
[ServiceContract]
public interface IClassPost
{
[WebInvoke(ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/POST/?json={jsonString}", Method = "POST")]
string DecodePost(string jsonString);
}
於是最後,我在同一個文件中的兩個相同的類:
public class ClassPost : IClassPost
{
public string DecodePost(string queryString)
{
string Deserialized = JsonCleaner.CleanAllWhiteSpace(JsonConvert.DeserializeObject(queryString).ToString());
return Deserialized;
}
上得到解碼類是相同的,相同的方法和班級。
我怎麼能得到更多的信息,爲什麼這是失敗的,或者我做錯了什麼? (到目前爲止,堆棧溢出或其他問題似乎都沒有相同的問題/解決方案)。