title: set content type for xml response in spring
body: <p>I have this method that returns an object which is then serialized.</p>
  
  <p>I'd like to set the content type of the response (e.g. as <code>application/xml</code>).</p>
  
  <p>How can I do this?</p>
  
  <p>I have found other posts but they are not very clear about how to do this for xml type</p>
  
  <pre><code>@RequestMapping(value = "/Disco/GetAreasAtLevel", method = RequestMethod.GET)
  @ResponseBody
  public GetAreasAtLevelResponseElement getAreasAtLevel(@RequestParam("AreaId") String areaId) {
          GetAreasAtLevelResponseElement root = new GetAreasAtLevelResponseElement();
          root.setArea("TEST");
          return root;
      }
  </code></pre>
  
  <p>This is my spring-ws-servlet.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:sws="http://www.springframework.org/schema/web-services"
  xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"&gt;
  
    &lt;context:component-scan base-package="com.porism"/&gt;
  
    &lt;sws:annotation-driven/&gt;
      &lt;tx:annotation-driven /&gt;
  
    &lt;util:properties id="sqlProperties" location="classpath:sql.properties"/&gt;
  
  &lt;bean id="OAuth" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"&gt;
    &lt;property name="schema" ref="schema"/&gt;
    &lt;property name="portTypeName" value="OAuth"/&gt;
    &lt;property name="locationUri" value="/soap/OAuthService/"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema"&gt;
      &lt;property name="xsd" value="WEB-INF/OAuthContract.xsd"/&gt;
  &lt;/bean&gt;
  
      &lt;bean id="dataSource"
          class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://192.168.50.171:3306/testtoolDev" /&gt;
          &lt;property name="username" value="" /&gt;
          &lt;property name="password" value="" /&gt;
  
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="configLocations" value="classpath*:/hibernate.cfg.xml"/&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="testtoolDAO" class="com.porism.dao.testtoolDAOImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  
    &lt;bean class="org.springframework.http.converter.AbstractHttpMessageConverter"&gt;
      &lt;property name="messageConverters"&gt;
           &lt;bean class="org.springframework.http.converter.StringHttpMessageConverter"&gt;
              &lt;property name="supportedMediaTypes" value="application/xml"/&gt;
           &lt;/bean&gt;
        &lt;/property&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="oAuthDAO" class="com.porism.oauth.dao.OAuthDAOImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory"&gt;
              &lt;ref bean="sessionFactory" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>