title: How to customize spring webservice's PayloadValidatingInterceptor response message?
body: <p>I have a java web service application built with jaxb and spring webservice.</p>
  
  <p>I have a complex type in a xsd like this:</p>
  
  <pre><code>...
  
  &lt;complexType name="GetRecordsRequest"&gt;
      &lt;sequence&gt;
          &lt;element name="maxRecords" type="int" maxOccurs="1" minOccurs="1"/&gt;
      &lt;/sequence&gt;
  &lt;/complexType&gt;
  
  ...
  </code></pre>
  
  <p>Using <strong>xjc</strong>, I had the jaxb class generated from xsd:</p>
  
  <pre><code>public class GetRecordsRequest {
      protected int maxRecords;
  
      public int getMaxRecords() {
          return maxRecords;
      }
  
      public void setMaxRecords(int value) {
          this.maxRecords = value;
      }
  }
  </code></pre>
  
  <p>I used <strong>PayloadValidatingInterceptor</strong> in spring context.xml to make sure user can't input anything besides integer for maxRecords:</p>
  
  <pre><code>&lt;bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"&gt;
      &lt;property name="interceptors"&gt;
          &lt;list&gt;
              &lt;ref local="validatingInterceptor" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"&gt;
      &lt;property name="schema" value="/WEB-INF/schemas/webservice.xsd" /&gt;
      &lt;property name="validateRequest" value="true" /&gt;
      &lt;property name="validateResponse" value="true" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>When I entered this soap request xml in Soap UI:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.test.com/ns1"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;ns1:GetRecordsRequest&gt;
           &lt;ns1:maxRecords&gt;&lt;/ns1:maxRecords&gt;
        &lt;/ns1:GetRecordsRequest&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>The response message I got is:</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;SOAP-ENV:Header/&gt;
     &lt;SOAP-ENV:Body&gt;
        &lt;SOAP-ENV:Fault&gt;
           &lt;faultcode&gt;SOAP-ENV:Client&lt;/faultcode&gt;
           &lt;faultstring xml:lang="en"&gt;Validation error&lt;/faultstring&gt;
           &lt;detail&gt;
              &lt;spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws"&gt;cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'.&lt;/spring-ws:ValidationError&gt;
              &lt;spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws"&gt;cvc-type.3.1.3: The value '' of element 'cis:maxRecords' is not valid.&lt;/spring-ws:ValidationError&gt;
           &lt;/detail&gt;
        &lt;/SOAP-ENV:Fault&gt;
     &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>You can see the result is two lines cryptic  message for just one field. Can I make the response message more prettier by making just one line? Is there a way to customize the validation error response message?</p>