djeeg
04-04-2006, 10:07 AM
I was looking for an ajax framework to put into my application and had initially looked at Atlas from Microsoft, but to integrate it you needed to use a custom .asmx handler, which would conflict with my current spring enabled asmx handler. Instead I tried dabbling a little with MagicAjax.Net, which only required a httpmodule. This was good for the learning phase and it worked really well (though there’s no direct integrate with it and spring). Though now I want to put webparts into my site, and atlas is now the best choice for my ajax framework.
To this end I needed to write a new .asmx hanlder that would split between my spring definitions and the custom one for atlas.
[PermissionSet(SecurityAction.InheritanceDemand , Unrestricted = true)]
public class WebServiceHandlerFactory : Microsoft.Web.Services.ScriptHandlerFactory, IHttpHandlerFactory {
private static readonly MethodInfo CoreGetHandler =
typeof(System.Web.Services.Protocols.WebServiceHan dlerFactory).GetMethod("CoreGetHandler", BindingFlags.NonPublic | BindingFlags.Instance, null,
new Type[] { typeof(Type), typeof(HttpContext), typeof(HttpRequest), typeof(HttpResponse) }, null);
IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string url, string path) {
new AspNetHostingPermission(AspNetHostingPermissionLev el.Minimal).Demand();
string serviceName = WebUtils.GetPageName(url);
IApplicationContext appContext = WebApplicationContext.Current;
if(appContext.ContainsObjectDefinition(serviceName )) {
Type serviceType = appContext.GetType(serviceName);
object o = CoreGetHandler.Invoke(new System.Web.Services.Protocols.WebServiceHandlerFac tory(), new object[] { serviceType, context, context.Request, context.Response });
return (IHttpHandler)o;
} else {
return base.GetHandler(context, requestType, url, path);
}
}
}
Actually it works good for me as Atlas looks a lot like MagicAjax but with $$ thrown at it.
To this end I needed to write a new .asmx hanlder that would split between my spring definitions and the custom one for atlas.
[PermissionSet(SecurityAction.InheritanceDemand , Unrestricted = true)]
public class WebServiceHandlerFactory : Microsoft.Web.Services.ScriptHandlerFactory, IHttpHandlerFactory {
private static readonly MethodInfo CoreGetHandler =
typeof(System.Web.Services.Protocols.WebServiceHan dlerFactory).GetMethod("CoreGetHandler", BindingFlags.NonPublic | BindingFlags.Instance, null,
new Type[] { typeof(Type), typeof(HttpContext), typeof(HttpRequest), typeof(HttpResponse) }, null);
IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string url, string path) {
new AspNetHostingPermission(AspNetHostingPermissionLev el.Minimal).Demand();
string serviceName = WebUtils.GetPageName(url);
IApplicationContext appContext = WebApplicationContext.Current;
if(appContext.ContainsObjectDefinition(serviceName )) {
Type serviceType = appContext.GetType(serviceName);
object o = CoreGetHandler.Invoke(new System.Web.Services.Protocols.WebServiceHandlerFac tory(), new object[] { serviceType, context, context.Request, context.Response });
return (IHttpHandler)o;
} else {
return base.GetHandler(context, requestType, url, path);
}
}
}
Actually it works good for me as Atlas looks a lot like MagicAjax but with $$ thrown at it.