spring.net

How do inject a property with Spring Framework .NET on a web service?


I have a web service with a property that I would like injected by Spring Framework .NET. There is no error message, and yet no injecting. What am I doing wrong?

Here is what I have for the xml file:

  <object type="MyCompany.MyProject.Business.MyClass">
    <property name="PaymentService" ref="PaymentService" />
  </object> 

Here is what I have for the code:

namespace MyCompany.MyProject.Web
{
    public class MyService : WebService
    {
        public IPaymentService PaymentService { get; set; }
    }
}

Solution

  • Here is what I ended up doing. We had to have an application context:

    IPaymentService paymentService = (IPaymentService) SecurityHelper.GetAppContext().GetObject("PaymentService");
    
            public static IApplicationContext GetAppContext()
            {
                if (WebApplicationContext.Current == null) throw new Exception("Spring not initialized");
                IApplicationContext context = WebApplicationContext.Current;
                if (context == null) throw new Exception("Spring context not initialized");
                return context;
            }