IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { IHttpHandler handler = null; if (context.Request.QueryString != null) pathTranslated = getPathTranslatedFromSiteGeneratorGUI(url, pathTranslated); // check if it is an .aspx page if (".aspx" == Path.GetExtension(pathTranslated)) { context.RewritePath(url, url, context.Request.QueryString.ToString()); handler = PageParser.GetCompiledPageInstance(url, pathTranslated, context); } else if (".asmx" == Path.GetExtension(pathTranslated).ToLower()) { WebServiceHandlerFactory wshf = new WebServiceHandlerFactory(); handler = wshf.GetHandler(context, requestType, url, pathTranslated); } else { ProcessStaticContent(pathTranslated); // Process page and HttpContext.Current.Response.End(); // end here } return handler; }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { WebServiceHandlerFactory wshFactory = new WebServiceHandlerFactory(); return wshFactory.GetHandler( HttpContext.Current, "GET,POST", VirtualPath, HttpContext.Current.Server.MapPath(VirtualPath)); }
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { var webServiceType = GetWebService(context.Request, GetServiceName(url)); var wshf = new System.Web.Services.Protocols.WebServiceHandlerFactory(); var coreGetHandler = typeof(WebServiceHandlerFactory).GetMethod("CoreGetHandler", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var httpHandler = (IHttpHandler)coreGetHandler.Invoke(wshf, new object[] { webServiceType, context, context.Request, context.Response }); return httpHandler; }
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { var webServiceType = GetWebService(context.Request, GetServiceName(url)); var wshf = new System.Web.Services.Protocols.WebServiceHandlerFactory(); var coreGetHandler = typeof(WebServiceHandlerFactory).GetMethod("CoreGetHandler", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var httpHandler = (IHttpHandler)coreGetHandler.Invoke(wshf, new object[] { webServiceType, context, context.Request, context.Response }); return(httpHandler); }
public override void ProcessMubbleRequest(System.Web.HttpContext context) { DateTime startDate = DateTime.Now; WebServiceHandlerFactory factory = new WebServiceHandlerFactory(); IHttpHandler handler = factory.GetHandler(context, "get", "~/WebServices/Content.asmx", ""); handler.ProcessRequest(context); }
public void handle() { var clrType = wsp.ProxyAssembly.GetTypes().First(a => a.BaseType == typeof (WebServiceExtended)); var factory = new WebServiceHandlerFactory(); var context = HttpContext.Current; context.Items["SoapServerType"] = type; context.Items["SoapServerDynamicWebServiceProxy"] = wsp; var handler = (IHttpHandler) coreGetHandler.Invoke(factory, new object[] {clrType, context, context.Request, context.Response}); handler.ProcessRequest(context); }
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { WebServiceHandlerFactory factory = new WebServiceHandlerFactory(); MethodInfo method = typeof (WebServiceHandlerFactory).GetMethod("CoreGetHandler", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] {typeof (Type), typeof (HttpContext), typeof (HttpRequest), typeof (HttpResponse)}, null); return (IHttpHandler) method.Invoke(factory, new object[] { this.GetType(), context, context.Request, context.Response }); }
public ScriptHandlerFactory () { _wsFactory = new WebServiceHandlerFactory (); }
public ScriptHandlerFactory () { fallback = new WebServiceHandlerFactory(); }
public void ReleaseHandler(IHttpHandler handler) { var wshf = new System.Web.Services.Protocols.WebServiceHandlerFactory(); wshf.ReleaseHandler(handler); }
public void ReleaseHandler(IHttpHandler handler) { var wshf = new System.Web.Services.Protocols.WebServiceHandlerFactory(); wshf.ReleaseHandler(handler); }
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { IHttpHandler HttpHandler = null; try { // Request Hosting permissions new AspNetHostingPermission(AspNetHostingPermissionLevel.Minimal).Demand(); // Try to get the type associated with the request (On a name to type basis) Type WebServiceType = this.GetServiceType(Path.GetFileNameWithoutExtension(pathTranslated)); // if we did not find any send it on to the original ajax script service handler. if (WebServiceType == null) { // [REFLECTION] Get the internal class System.Web.Script.Services.ScriptHandlerFactory create it. IHttpHandlerFactory ScriptHandlerFactory = (IHttpHandlerFactory)System.Activator.CreateInstance(AjaxAssembly.GetType("System.Web.Script.Services.ScriptHandlerFactory")); _usedHandlerFactory = ScriptHandlerFactory; return ScriptHandlerFactory.GetHandler(context, requestType, url, pathTranslated); } // [REFLECTION] get the Handlerfactory : RestHandlerFactory (Handles Javascript proxy Generation and actions) IHttpHandlerFactory JavascriptHandlerFactory = (IHttpHandlerFactory)System.Activator.CreateInstance(AjaxAssembly.GetType("System.Web.Script.Services.RestHandlerFactory")); // [REFLECTION] Check if the current request is a Javasacript method // JavascriptHandlerfactory.IsRestRequest(context); System.Reflection.MethodInfo IsScriptRequestMethod = JavascriptHandlerFactory.GetType().GetMethod("IsRestRequest", BindingFlags.Static | BindingFlags.NonPublic); if ((bool)IsScriptRequestMethod.Invoke(null, new object[] { context })) { // Remember the used factory for later in ReleaseHandler _usedHandlerFactory = JavascriptHandlerFactory; // Check and see if it is a Javascript Request or a request for a Javascript Proxy. bool IsJavascriptDebug = string.Equals(context.Request.PathInfo, "/jsdebug", StringComparison.OrdinalIgnoreCase); bool IsJavascript = string.Equals(context.Request.PathInfo, "/js", StringComparison.OrdinalIgnoreCase); if (IsJavascript || IsJavascriptDebug) { // [REFLECTION] fetch the constructor for the WebServiceData Object ConstructorInfo WebServiceDataConstructor = AjaxAssembly.GetType("System.Web.Script.Services.WebServiceData").GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Type), typeof(bool) }, null); // [REFLECTION] fetch the constructor for the WebServiceClientProxyGenerator ConstructorInfo WebServiceClientProxyGeneratorConstructor = AjaxAssembly.GetType("System.Web.Script.Services.WebServiceClientProxyGenerator").GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(string), typeof(bool) }, null); // [REFLECTION] get the method from WebServiceClientProxy to create the javascript : GetClientProxyScript MethodInfo GetClientProxyScriptMethod = AjaxAssembly.GetType("System.Web.Script.Services.ClientProxyGenerator").GetMethod("GetClientProxyScript", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { AjaxAssembly.GetType("System.Web.Script.Services.WebServiceData") }, null); // [REFLECTION] We invoke : // new WebServiceClientProxyGenerator(url,false).WebServiceClientProxyGenerator.GetClientProxyScript(new WebServiceData(WebServiceType)); string Javascript = (string)GetClientProxyScriptMethod.Invoke( WebServiceClientProxyGeneratorConstructor.Invoke(new Object[] { url, IsJavascriptDebug }) , new Object[] { WebServiceDataConstructor.Invoke(new object[] { WebServiceType, false }) } ); // The following caching code was copied from the original assembly, read with Reflector, comments were added manualy. #region Caching // Check the assembly modified time and use it as caching http header DateTime AssemblyModifiedDate = GetAssemblyModifiedTime(WebServiceType.Assembly); // See "if Modified since" was requested in the http headers, and check it with the assembly modified time string s = context.Request.Headers["If-Modified-Since"]; DateTime TempDate; if (((s != null) && DateTime.TryParse(s, out TempDate)) && (TempDate >= AssemblyModifiedDate)) { context.Response.StatusCode = 0x130; return null; } // Add HttpCaching data to the http headers if (!IsJavascriptDebug && (AssemblyModifiedDate.ToUniversalTime() < DateTime.UtcNow)) { HttpCachePolicy cache = context.Response.Cache; cache.SetCacheability(HttpCacheability.Public); cache.SetLastModified(AssemblyModifiedDate); } #endregion // Set Add the javascript to a new custom handler and set it in HttpHandler. HttpHandler = new JavascriptProxyHandler(Javascript); return HttpHandler; } else { IHttpHandler JavascriptHandler = (IHttpHandler)System.Activator.CreateInstance(AjaxAssembly.GetType("System.Web.Script.Services.RestHandler")); // [REFLECTION] fetch the constructor for the WebServiceData Object ConstructorInfo WebServiceDataConstructor = AjaxAssembly.GetType("System.Web.Script.Services.WebServiceData").GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Type), typeof(bool) }, null); // [REFLECTION] get method : JavaScriptHandler.CreateHandler MethodInfo CreateHandlerMethod = JavascriptHandler.GetType().GetMethod("CreateHandler", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { AjaxAssembly.GetType("System.Web.Script.Services.WebServiceData"), typeof(string) }, null); // [REFLECTION] Invoke CreateHandlerMethod : // HttpHandler = JavaScriptHandler.CreateHandler(WebServiceType,false); HttpHandler = (IHttpHandler)CreateHandlerMethod.Invoke(JavascriptHandler, new Object[] { WebServiceDataConstructor.Invoke(new object[] { WebServiceType, false }) , context.Request.PathInfo.Substring(1) } ); } return HttpHandler; } else { // Remember the used factory for later in ReleaseHandler IHttpHandlerFactory WebServiceHandlerFactory = new WebServiceHandlerFactory(); _usedHandlerFactory = WebServiceHandlerFactory; // [REFLECTION] Get the method CoreGetHandler MethodInfo CoreGetHandlerMethod = _usedHandlerFactory.GetType().GetMethod("CoreGetHandler", BindingFlags.NonPublic | BindingFlags.Instance); // [REFLECTION] Invoke the method CoreGetHandler : // WebServiceHandlerFactory.CoreGetHandler(WebServiceType,context,context.Request, context.Response); HttpHandler = (IHttpHandler)CoreGetHandlerMethod.Invoke(_usedHandlerFactory, new object[] { WebServiceType, context, context.Request, context.Response } ); return HttpHandler; } } // Because we are using Reflection, errors generated in reflection will be an InnerException, // to get the real Exception we throw the InnerException it. catch (TargetInvocationException e) { throw e.InnerException; } }