Answered by:
WCF JSON Service and URI Template

Question
-
User-1129879462 posted
What should be the URITemplate for the following method?
How do I invoke the method from JQuery?!
[OperationContract] [WebInvoke( Method="GET", UriTemplate="FireSelectionRule/{ruleName,lists}", RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json, BodyStyle=WebMessageBodyStyle.Wrapped ) ]
public IList<string> FireSelectionRule(string ruleName, Dictionary<string, string> lists);
Wednesday, November 27, 2013 1:20 AM
Answers
-
User260886948 posted
Hi,
>>What should be the URITemplate for the following method.
In my mind, it will be better that just use a simple string for the Get method and then convert it to an Array (or a list) in the method, using the split method.Your Interface should look something like this:
[OperationContract] [WebInvoke( Method="GET", UriTemplate="FireSelectionRule/ruleName/lists}", RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json, BodyStyle=WebMessageBodyStyle.Wrapped ) ] public IList<string> FireSelectionRule(string ruleName, string lists);
Your implementation:
public IList<string> FireSelectionRule(string ruleName, string lists); { IList<string> parameteres = new List<string>(); string[] pp = lists.Split(','); parameteres = pp.ToList(); return parameteres; }
And call it like this in your browser:
http://localhost:8731/MyServer/second/a,b,cFor more information, pease try to refer to:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/2341c11e-92b3-4da4-aba5-858054f46c80/wcf-rest-webget-accepting-arrays-of-parameters?forum=wcf .>>How do I invoke the method from JQuery
For this question, please try to refer to the following articles:
#Consuming WCF REST Services Using JQuery AJAX Calls:
http://www.codeproject.com/Articles/128478/Consuming-WCF-REST-Services-Using-jQuery-AJAX-Call .#How to call a WCF REST Services using Jquery:
http://www.codeproject.com/Articles/182393/Create-a-REST-service-with-WCF-and-consume-it-usin .Best Regards,
Amy Peng- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, November 27, 2013 11:24 PM
All replies
-
User-1662538993 posted
Check this links -http://www.codeproject.com/Articles/132809/Calling-WCF-Services-using-jQuery
Wednesday, November 27, 2013 11:43 AM -
User260886948 posted
Hi,
>>What should be the URITemplate for the following method.
In my mind, it will be better that just use a simple string for the Get method and then convert it to an Array (or a list) in the method, using the split method.Your Interface should look something like this:
[OperationContract] [WebInvoke( Method="GET", UriTemplate="FireSelectionRule/ruleName/lists}", RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json, BodyStyle=WebMessageBodyStyle.Wrapped ) ] public IList<string> FireSelectionRule(string ruleName, string lists);
Your implementation:
public IList<string> FireSelectionRule(string ruleName, string lists); { IList<string> parameteres = new List<string>(); string[] pp = lists.Split(','); parameteres = pp.ToList(); return parameteres; }
And call it like this in your browser:
http://localhost:8731/MyServer/second/a,b,cFor more information, pease try to refer to:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/2341c11e-92b3-4da4-aba5-858054f46c80/wcf-rest-webget-accepting-arrays-of-parameters?forum=wcf .>>How do I invoke the method from JQuery
For this question, please try to refer to the following articles:
#Consuming WCF REST Services Using JQuery AJAX Calls:
http://www.codeproject.com/Articles/128478/Consuming-WCF-REST-Services-Using-jQuery-AJAX-Call .#How to call a WCF REST Services using Jquery:
http://www.codeproject.com/Articles/182393/Create-a-REST-service-with-WCF-and-consume-it-usin .Best Regards,
Amy Peng- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, November 27, 2013 11:24 PM