using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xml.Serialization; using System.Reflection; namespace api { public class SearchService { public static void ProcessRequest(HttpContext context) { string op = context.Request.QueryString["op"]; if (context.Request.Url.AbsolutePath.EndsWith("Search.svc")) { Search search = new Search(); List args = new List(); foreach (ParameterInfo pi in search.GetType().GetMethod(op).GetParameters()) { string value = context.Request.QueryString[pi.Name]; args.Add(value); } context.Response.ContentType = "application/xml"; object retVal = search.GetType().GetMethod(op).Invoke(search, args.ToArray()); //serialize return value to XML on the response stream XmlSerializer xs = new XmlSerializer(retVal.GetType()); xs.Serialize(context.Response.OutputStream, retVal); context.Response.End(); } } } }