【发布时间】:2013-11-22 10:39:06
【问题描述】:
我遇到了一个我无法解决的问题。 我正在用 ajax 和 json 写一篇文章以通过 WCF 传递数据,但不起作用……给了我不好的请求。 我不知道我做错了什么......
我的代码是这样的
Service1.svc.cs:
namespace Teste
{
public class Service1 : IService1
{
public string GetData()
{
string getdata = "hello";
return string.Format("You entered" + getdata);
}
public string GetDataName(string Name)
{
return string.Format("You entered" + Name);
}
}
}
IService1.cs:
namespace Teste
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "GetData", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
string GetData();
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "GetDataName", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
string GetDataName(string Name);
}
}
谁能告诉我为什么当我用这个名字发帖时,它给了我不好的要求?
问候
【问题讨论】: