我认为这是可能的,下面是我所了解的解决方案。
WCF接口
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(UriTemplate = "HelloWorld/{test}")]
string HelloWorld(string test);
}
WCF接口实现
public class Service : IService1
{
return "Success from Hello World";
}
从阿贾克斯jQuery的
$.ajax({
type: 'GET',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
url: baseUrl + '/HelloWorld/TestString',
success: function (response) {
alert('Ping reply: ' + response);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
var jsonFault = JSON.parse(XMLHttpRequest.responseText);
alert('Reason: ' + jsonFault.Reason + '<br />Detail: ' + jsonFault.DetailedInformation);
}
});
呼叫我试着用单一的参数。如果我错了,请更多地解释我。
查询欢迎...
我认为可以通过为该方法定义URI模板HelloWorld(string test){} –