I have an application that uses Spring.NET for IOC, as well as many other features that it provides. The problem I am now trying to tackle is how to setup something similar to a WebServiceProxyFactory to auto-proxy a web service that I want to consume in the app. This configuration works great for a single service endpoint.
<object id="MyServiceClient" type="Spring.Web.Services.WebServiceProxyFactory, Spring.Services">
<property name="ServiceUri" value="https://my.service1.net/service.asmx"/>
<property name="ServiceInterface" value="Sample.IServiceClient1"/>
<property name="WebServiceProxyBaseType" value="Sample.SecureWebServiceProxy, Sample"/>
<property name="MemberAttributes">
<dictionary>
<entry key="*">
<list>
<object type="System.Web.Services.Protocols.SoapHeaderAttribute, System.Web.Services">
<constructor-arg value="ServiceAuthenticationHeader" />
<property name="Direction" value="In" />
</object>
<object type="System.Web.Services.Protocols.SoapHeaderAttribute, System.Web.Services">
<constructor-arg value="ServiceErrorStatus" />
<property name="Direction" value="Out" />
</object>
</list>
</entry>
</dictionary>
</property>
<property name="ProductTemplate">
<object>
<property name="ServiceAuthenticationHeader" ref="ServiceAuthenticationHeader" />
<property name="ServiceErrorStatus" ref="ServiceErrorStatus" />
</object>
</property>
However, now I need to handle potentially unlimited numbers of endpoints all based upon configuration settings in the app. The configuration would tell me the number and details about the service endpoints, which could be hosted at various URLs but implement the same interface.
What I can't figure out is how to configure Spring.NET to allow me to swap the ServiceUri so that it could change for each object generated by the factory. I would call the Factory's GetObject method, but would like to somehow specify which ServiceUri it should use before generating the proxy object.
For now I am thinking that just implementing a custom IFactoryObject that does the hard work behind the scenes is the best way to go.
Thanks