Results 1 to 6 of 6

Thread: AOP and Web Services

  1. #1
    Join Date
    May 2005
    Location
    tyson's corner, va
    Posts
    55

    Default AOP and Web Services

    Is there a way to intercept method calls to a web service? My config for web services looks something like this:
    Code:
    <object name="EventService" type="Event.EventService, WebService" abstract="true"/>
    <object id="EventServiceExporter" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
    	<property name="TargetName"><value>EventService</value></property> 
        ...
    </object>
    The trouble seems to be that the "abstract=true" attribute makes the EventService object a bad target for the ProxyFactoryObject as in:
    Code:
    <object id="EventServiceProxy" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
    	<property name="TargetName"><value>EventService</value></property>
    	<property name="IsSingleton">
    		<value>true</value>
    	</property>
    	<property name="interceptorNames">
    		<list>
    		...	
          </list>
    	</property>
    </object>
    
    <object name="EventService" type="Event.EventService, WebService" abstract="true"/>
    <object id="EventServiceExporter" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
    	<property name="TargetName"><value>EventServiceProxy</value></property> 
        ...
    </object>
    Making the EventServiceProxy object abstract to statisfy the WebServiceExporter is not possible.

    I made one other try, by trying to ProxyFactoryObject the WebServiceExporter as in:
    Code:
    <object id="EventServiceProxy" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
    	<property name="TargetName"><value>EventServiceExporter</value></property>
    	<property name="IsSingleton">
    		<value>true</value>
    	</property>
    	<property name="interceptorNames">
    		<list>
    		...	
        </list>
    	</property>
    </object>
    <object name="EventService" type="Event.EventService, WebService" abstract="true"/>
    <object id="EventServiceExporter" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
    	<property name="TargetName"><value>EventService</value></property> 
        ...
    </object>
    That attempt seemed to be thwarted as well.

    Is there a way to do this?

    Best regards,

    Steve

  2. #2
    Join Date
    Sep 2004
    Location
    Belgrade, Serbia
    Posts
    613

    Default

    Damn, looks like you are really using Spring to the max Not only are you using "yet-to-be-released" WebServiceExporter, but you want to apply aspects to it as well...

    Short answer is that you can't do it right now, and I was hoping that nobody would try it just yet, which would give me some time to remedy that

    Here is why:

    WebServiceExporter creates a web service proxy for the specified target and registers it as a new object in the context by appending '.webservice' to target's ID ("EventService.webservice" in your case).

    This new object is what you need to proxy using AOP ProxyFactory object in order to apply advice to it. Problem is that even if you manage to do that, WebServiceHandlerFactory will still use 'EventService.webservice' as a key to look up your exported web service, so your AOP proxy will be ignored.

    I can think of couple solutions, but none of them are very elegant. Let me think about it some more and I'll get back to you, hopfully with a solution that isn't a hack

    - Aleks

  3. #3
    Join Date
    May 2005
    Location
    tyson's corner, va
    Posts
    55

    Default

    Yeah...I am getting a little bit ahead. You can always count of me for that. [smile] I have a strange knack for finding and ultimately needing those functions that are just outside of the release schedule.

    I"m finding the WebServiceExporter most excellent, by the way. Even in its CVS-form it's been happily serving up web services for me for some time now.

    In regards to this:
    WebServiceExporter creates a web service proxy for the specified target and registers it as a new object in the context by appending '.webservice' to target's ID ("EventService.webservice" in your case).
    I'd forgotten that completly. I remember that from my early days of using the exporter.

    Look forward to any solutions you may have. Thanks!

    Steve

  4. #4
    Join Date
    Sep 2004
    Location
    Belgrade, Serbia
    Posts
    613

    Default

    Ok, I believe solution for your problem is in CVS and documentation is on the Wiki (Scroll down to "Exporting AOP Proxy as a Web Service" section)

    Few things to note:

    1. Exported web service class has to implement service interface. Obviously, AOP proxy will have an interface, but unfortunately I had to impose this requirement accross the board -- only classes that implement an interface can be exported now.

    2. TargetObjectName property was renamed back to TargetName, for consistency reasons (for example, ProxyFactoryObject also has TargetName property), so you will have to change your definitions accordingly.

    3. WebServiceExporter target *should not be* declared as abstract. You should configure it just like any other object, either as singleton (default) or prototype. Instead of calling IObjectFactory.ConfigureObject, generated web service proxy now calls (correctly) IObjectFactory.GetObject, which will fail if requested object is abstract.

    4. Expose<BlahBlah> property was removed from the WebServiceExporter and Interfaces property was added, which allows you to specify which interfaces should be exported. By default, all members of all interfaces are exported. Make sure that you remove any references to 'Expose<XXX>' (can't remember the name now) property from your web service exporter configurations.

    I guess that's it. Try it and let me know if that's what you had in mind.

    Regards,

    Aleks

  5. #5
    Join Date
    May 2005
    Location
    tyson's corner, va
    Posts
    55

    Default

    You can't see, but I'm smiling. Most excellent work!

    I like that the ExposeAllMethods property is gone. I didn't dig deeper, but I assume that the Methods property is gone with it? I very much like that my config files are a lot shorter with these changes.

    Thanks for the help.

    Steve

  6. #6
    Join Date
    Sep 2004
    Location
    Belgrade, Serbia
    Posts
    613

    Default

    Great, I'm glad you like it

    Methods property is still there, but it's still optional. The only way you would use it is if you want to add descriptions to your web methods. Otherwise, you can do just fine without it.

    - Aleks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •