yagiz
10-19-2006, 06:10 PM
Hi,
We are developing an application using Web Services in .NET 2.0 (using Visual Studio 2005 for web application projects template) and Spring.AOP. We've come across an unexpected issue while exporting the AOP Proxy as a Web Service.
We have a WebService called MembershipService.asmx that implements the interface IMembershipService. We want to apply security to every method in this webservice and we chose AOP to intercept the execution and place queries to our SecurityManager. We created a class called SecurityInterceptor that implements the IMethodInterceptor.
So the Web.Config look like:
<system.web>
<httpHandlers>
<clear/>
<add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web" />
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" />
</httpModules>
………………
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
</sectionGroup>
…………………
<spring>
<context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
<resource uri="file://C:\Dev\App\Src\App.MemberShip.Web.Service\Security Objects.xml" />
</context>
</spring>
And in the Spring context we have:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net" >
<object name="MembershipService.asmx" type="App.MembershipService, App.MemberShip.Web.Service" abstract="true"/>
<object id="SecurityAdvice"
type=" App.MemberShip.Web.Service.SecurityInterceptor, App.MemberShip.Web.Service"/>
<object id="MyMembershipService" type=" App.MemberShip.Web.Service.MembershipService, App.MemberShip.Web.Service"/>
<object id="MyMembershipServiceProxy" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="TargetName" value="MyMembershipService"/>
<property name="IsSingleton" value="true"/>
<property name="InterceptorNames">
<list>
<value>SecurityAdvice</value>
</list>
</property>
</object>
<object id="MyMemberShipServiceExporter" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
<property name="TargetName" value="MyMembershipServiceProxy"/>
<property name="Name" value="MyMembershipService"/>
<property name="Namespace" value="http://decaresystems.ie/daisy/membership/2006"/>
<property name="Description" value="Membership Service"/>
<property name="Interfaces">
<list>
<value>App.MemberShip.Web.Service.IMembershipService</value>
</list>
</property>
</object>
If we use XmlObjectFactory to get the WebService instance, everything works fine:
IApplicationContext ctx = ContextRegistry.GetContext();
IMembershipService i=ctx.GetObject("MyMemberShipServiceExporter") as IMembershipService;
i.GetSubscribersBySsn(ssn);
However, if we call the WebService through a Web request, Spring.NET HttpHandlerFactory is invoked but it just creates the real WebService and not the Proxy. Therefore we cannot use AOP.
We tried to put a “Response.Write” within the WebServiceHandlerFactory and we noticed that the request is served with this factory without issues… So we don’t know why this factory is not creating the AOP Proxy…
Are we missing anything? Any ideas?
Thanks,
- Yagiz -
http://blog.decaresystems.ie
We are developing an application using Web Services in .NET 2.0 (using Visual Studio 2005 for web application projects template) and Spring.AOP. We've come across an unexpected issue while exporting the AOP Proxy as a Web Service.
We have a WebService called MembershipService.asmx that implements the interface IMembershipService. We want to apply security to every method in this webservice and we chose AOP to intercept the execution and place queries to our SecurityManager. We created a class called SecurityInterceptor that implements the IMethodInterceptor.
So the Web.Config look like:
<system.web>
<httpHandlers>
<clear/>
<add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web" />
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" />
</httpModules>
………………
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
</sectionGroup>
…………………
<spring>
<context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
<resource uri="file://C:\Dev\App\Src\App.MemberShip.Web.Service\Security Objects.xml" />
</context>
</spring>
And in the Spring context we have:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net" >
<object name="MembershipService.asmx" type="App.MembershipService, App.MemberShip.Web.Service" abstract="true"/>
<object id="SecurityAdvice"
type=" App.MemberShip.Web.Service.SecurityInterceptor, App.MemberShip.Web.Service"/>
<object id="MyMembershipService" type=" App.MemberShip.Web.Service.MembershipService, App.MemberShip.Web.Service"/>
<object id="MyMembershipServiceProxy" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="TargetName" value="MyMembershipService"/>
<property name="IsSingleton" value="true"/>
<property name="InterceptorNames">
<list>
<value>SecurityAdvice</value>
</list>
</property>
</object>
<object id="MyMemberShipServiceExporter" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
<property name="TargetName" value="MyMembershipServiceProxy"/>
<property name="Name" value="MyMembershipService"/>
<property name="Namespace" value="http://decaresystems.ie/daisy/membership/2006"/>
<property name="Description" value="Membership Service"/>
<property name="Interfaces">
<list>
<value>App.MemberShip.Web.Service.IMembershipService</value>
</list>
</property>
</object>
If we use XmlObjectFactory to get the WebService instance, everything works fine:
IApplicationContext ctx = ContextRegistry.GetContext();
IMembershipService i=ctx.GetObject("MyMemberShipServiceExporter") as IMembershipService;
i.GetSubscribersBySsn(ssn);
However, if we call the WebService through a Web request, Spring.NET HttpHandlerFactory is invoked but it just creates the real WebService and not the Proxy. Therefore we cannot use AOP.
We tried to put a “Response.Write” within the WebServiceHandlerFactory and we noticed that the request is served with this factory without issues… So we don’t know why this factory is not creating the AOP Proxy…
Are we missing anything? Any ideas?
Thanks,
- Yagiz -
http://blog.decaresystems.ie