合同
[OperationContract]
[WebGet(UriTemplate = "Filter/{paramName:paramValue}/"),
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string[] Filter(string paramNameAndparamValue);
实施
public string Filter(string paramNameAndparamValue)
{
string[] tmp = paramNameAndparamValue.split(':');
// do something ...
}
为什么要将这个restful方法传递给将用作json对象的参数并避免使用string.split
?
答案 0 :(得分:1)
您可以尝试以下
<强> Iservice.cs 强>
[OperationContract]
[WebGet(UriTemplate = "Filter/{paramName}/{paramValue}"),
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string[] Filter(string paramName,string paramValue);
service .cs
public string[] Filter(string paramName,string paramValue);
{
//your code;
}