QAT Insights

Highlighting recent QAT solution releases, insights, service and industry information, upcoming events, case studies, and press releases.

The Spring.NET Web Service Exporter Part 2 – Setting up Web.config

June17

In my previous post I discussed advantages of choosing the Spring.NET web service exporter over the standard .NET mechanism through decoration with attributes. Now I would like to show how to set up an web service exporter. Basic configuration details for the Spring.NET Web Service Exporter can be found in the Spring.NET Documentation but my example will add some important aspects like registering custom objects and session access that are not included in the above link.

Of course, the Spring.NET framework needs to be installed. I’m using version 1.2.0; download it here. The various Spring DLLs will need to be referenced by the sample application (the DLLs that provide specialized support like, for example, for NHibernate, can be omitted).

For Spring to initialize automatically in an web application, settings need to be added to the Web.config file. It is good practice to separate the actual object configuration into one or more seperate files that the Web.config points to (in this case ~/config/Spring.xml). Here is an example of the Web.config entries – most are needed for setting up Spring.NET in general. The httpHandlers and typeAliases were added specifically for web service support:


<configuration>
...
  <configSections>
    <sectionGroup name="spring">
      <section name="typeAliases"
        type="Spring.Context.Support.TypeAliasesSectionHandler, Spring.Core"/>
      <section name="parsers"
        type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
      <section name="context"
        type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
      <section name="objects"
        type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
    </sectionGroup>
  </configSections>
...
  <system.web>
...
    <httpModules>
      <add name="Spring"
        type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
    </httpModules>
    <httpHandlers>
      <add verb="*" path="*.asmx"
        type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web"/>
    </httpHandlers>
  </system.web>
...
  <spring>
    <context>
      <!-- the file where the spring configuration resides -->
      <resource uri="~/config/Spring.xml" />
    </context>
    <typeAliases>
      <!-- needed if custom types need to be 
           registered with the web service exporter -->
      <alias name="XmlInclude"
        type="System.Xml.Serialization.XmlIncludeAttribute, System.Xml"/>
    </typeAliases>
  </spring>
...
</configuration>

Now we need to set up the Spring configuration and code a web service. I will go into more details in my next post.

Anke

posted under .NET, Web Services
2 Comments to

“The Spring.NET Web Service Exporter Part 2 – Setting up Web.config”

  1. On July 1st, 2009 at 6:28 am QAT Insights » Blog Archive » The Spring.NET Web Service Exporter Part 4 - Spring Configuration Says:

    [...] is the last part of the Spring.NET Web Service Exporter example. I’ve shown the Web.config entries and the application details. Now we are only missing the Spring configuration file – named [...]

  2. On September 21st, 2009 at 8:32 am QAT Insights » Blog Archive » The Spring.NET Web Service Exporter Part 3 – The Business Logic Says:

    [...] my previous posts here and here, I explained the advantages of using Spring.NET’s Web Service Exporter and how to initialize [...]