我認爲這是可能的,下面是我所瞭解的解決方案。
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){} –