PDA

View Full Version : Atlas ASP.NET


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.

Bruno Baia
04-20-2006, 11:38 PM
Hi,

i installed the lastest Atlas version (Avril CTP) and i investigate a little bit.

This IHttpHandlerFactory will not handle client browser access (with javascript) when enabled :

<webServices enableBrowserAccess="true" />


The javascript is used by Atlas controls, like the well known autoComplete textbox, so we need to take care of it.
You can see the javascript adding "/js" at the end of your web service url ("http://..../blabla.asmx/js").


I think it's possible to make a IHttpHandlerFactory implementation to enable DI/AOP for Atlas web services.
I'll ping back here if any progress.

-Bruno

djeeg
04-21-2006, 03:45 AM
Hi Bruno,

Yeah the fact that requests for the webservice come in as /js was the main reason i had to have my custom WebServiceHandlerFactory. You may also need this in your web.config:

<webServices>
<protocols>
<add name="HttpGet"/>
</protocols>
</webServices>

The only other issue i had was with HttpSession in webservices, but now that i understand it a lttle better i assume that in the spring web service exporter i just add:

<entry key="MyMethod">
<object type="System.Web.Services.WebMethodAttribute, System.Web.Services">
<property name="EnableSession" value="true"/>
</object>
</entry>

Bruno Baia
06-02-2006, 07:54 AM
Hi,

I forgot to reply to this threads, it can help with search results.

There is now an ASP.NET "Atlas" web services integration (http://forum.springframework.net/showthread.php?t=447) to allow DI and AOP for your ATLAS web services.


-Bruno