C# 我应该在哪里查找:未找到WCF Rest-POST端点
我已经对此进行了近两天的研究,这表明这将是一个非常简单的解决方案: 我有WCF休息服务。GET对于返回JSON非常有用,但是在POST中,我只接收到在Chrome和Fiddler中找不到的端点 我将提供GET和POST属性,以防我通过GET方法打破它C# 我应该在哪里查找:未找到WCF Rest-POST端点,c#,json,wcf,rest,wcf-endpoint,C#,Json,Wcf,Rest,Wcf Endpoint,我已经对此进行了近两天的研究,这表明这将是一个非常简单的解决方案: 我有WCF休息服务。GET对于返回JSON非常有用,但是在POST中,我只接收到在Chrome和Fiddler中找不到的端点 我将提供GET和POST属性,以防我通过GET方法打破它 <services> <service name="WCFServiceWebRole1.Class" behaviorConfiguration="serviceBehavior"> <e
<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>
最后,我在同一个文件中有两个相同的类:
public class ClassPost : IClassPost
{
public string DecodePost(string queryString)
{
string Deserialized = JsonCleaner.CleanAllWhiteSpace(JsonConvert.DeserializeObject(queryString).ToString());
return Deserialized;
}
GET上解码的类是相同的,相同的方法和类
我怎样才能得到更多关于为什么失败的信息,或者我做错了什么?
(到目前为止,堆栈溢出问题或其他问题似乎都没有相同的问题/解决方案)。这是我的服务合同中的一个问题 将其更改为单独的服务合同 将所有OperationContracts移动到一个服务合同中纠正了问题,因此看起来是这样的:
[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);
}
[ServiceContract]
public interface IClass
{
[WebInvoke(ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/GET/?json={jsonString}", Method = "GET")]
string Decode(string jsonString);
[WebInvoke(ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/POST/?json={jsonString}", Method = "POST")]
string DecodePost(string jsonString);
}