PDA

View Full Version : Can the target of WebServiceExporter be proxied?


EJS
11-29-2006, 09:43 PM
Hi All,

I couldn't find an answer to this question: I have a webservice using the WebServiceExporter. The target is an (ordinary) service that implements a service interface. Now I want to apply an AOP advice to methods of this service. I configured this as follows:

<object name="ljnResearchPane" type="EJSSD.LjnResearchPane.Core.LjnResearchService, EJSSD.LjnResearchPane.Core">
<property name="..." ref="..." />
</object>

<object id="researchServiceLoggingAroundAdvice" type="Spring.AOP.Support.NameMatchMethodPointcutAdvisor, Spring.AOP">
<property name="MappedNames" value="Register,Query"/>
<property name="Advice">
<object type="EJSSD.OfficeResearchService.AOP.ResearchServiceLog gingAdvice, EJSSD.OfficeResearchService"/>
</property>
</object>

<object id="ljnResearchPaneProxied" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="Target" ref="ljnResearchPane" />
<property name="InterceptorNames">
<list>
<value>researchServiceLoggingAroundAdvice</value>
</list>
</property>
</object>

<object id="ljnResearchPaneWebService" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
<property name="TargetName" value="ljnResearchPaneProxied"/>
<property name="Name" value="Research Pane"/>
<property name="Namespace" value="urn:Microsoft.Search"/>
<property name="Description" value="LJN Service Research Pane"/>
<property name="MemberAttributes">
<dictionary>
... methods
</dictionary>
</property>
</object>

This config gives the following exception:
Both Void AddAdvice(Int32, AopAlliance.Aop.IAdvice) and Void AddAdvice(AopAlliance.Aop.IAdvice) use the message name 'AddAdvice'. Use the MessageName property of the WebMethod custom attribute to specify unique message names for the methods.

The none proxied version works fine. I couldn't figure out why this error occurs...:confused:

Cheers,
EJ

tbroyer
11-30-2006, 08:31 AM
The WebServiceExporter exports each and every method; the MemberAttributes property allows you to add other attributes or to "configure" a WebMethod attribute (if you don't "manually" configure a WebMethod attribute for a given method, the WebMethodExporter will add one with default values for you).

I'm not 100%-sure but I think you should just use the ProxyInterfaces property of the WebServiceExporter (given that you don't use ProxyTargetType,I suppose your class implements an interface that you can use here).

My 2 c€nts…

EJS
11-30-2006, 09:22 AM
Hmmm, I want to apply the advice to the target of the WebServiceExporter, not to the type the WebServiceExporter creates. So in my configuration I replaced the target name to ljnResearchPaneProxied instead of ljnResearchPane (see the configuration). So the target of the WebServiceExporter becomes a proxied type as well. This now results in the error shown.

tbroyer
11-30-2006, 10:10 AM
Hmmm, I want to apply the advice to the target of the WebServiceExporter, not to the type the WebServiceExporter creates.

I know, and the problem is that a WebService cannot have more than one WebMethod with the same name (hence the suggestion to use the MethodName property of the WebMethodAttribute).

The AddAdvice overloaded methods are a side-effect of the proxy class generated by the ProxyFactoryObject. If you tell the WebServiceExporter to only export methods from your interface, they won't get exported and you shouldn't have the error anymore.

See http://forum.springframework.net/showthread.php?p=3675#post3675 and the answer from Bruno Baia in http://forum.springframework.net/showthread.php?p=3763#post3763

According to Bruno, this is fixed in CVS, so it'll be in the PR3 scheduled next week

EJS
11-30-2006, 08:06 PM
Thanks a lot! Specifying the interface fixed it. Now the weaved service is used.
Cool stuff!

EJ

rolandz
01-03-2007, 04:13 PM
There is also a thing like:

Spring.Web.Services.WebServiceProxyFactory, Spring.Services

what produces a proxy that publiszes all the stuff nicely through a web service :)