Ajax Autocomplete Webservice Call - Service Method, am I calling this correctly?
-
09-06-2019 - |
Question
Ok, so my method in my webservice requires a type to be passed, it is called in the ServiceMethod property of the AutoCompleteExtender, I am fuzzy about how I should do that so I called it like this:
ServiceMethod="DropDownLoad<<%=(typeof)subCategory%>>"
where subCategory is a page property that looks like this:
protected SubCategory subCategory
{
get
{
var subCategory = NHibernateObjectHelper.LoadDataObject<SubCategory>(Convert.ToInt32(Request.QueryString["SCID"]));
return subCategory;
}
}
Solution
I dont' think calling a Generic Method on a webservice is possible.
If you look at the service description of two identical methods, one generic, one not:
[WebMethod]
public string[] GetSearchList(string prefixText, int count)
{
}
[WebMethod]
public string[] GetSearchList2<T>(string prefixText, int count)
{
}
They are identical. It appears that both SOAP 1.x and HTTP POST do not allow this type of operation.
OTHER TIPS
You could use the AutoCompleteExtender's ContextKey parameter to use a single web method that accepted a type name as its context key. Then in the web method, use reflection and that parameter to return the desired string[].