Skip to content

Validations Sample

Max Wendel F. F. Araújo edited this page May 1, 2019 · 2 revisions

Movie-WS

Validations Sample

Null Element Validation Example

  • Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mov="http://www.abstract.com/movies-ws">
   <soapenv:Header/>
   <soapenv:Body>
      <mov:addMovieRequest>
         <mov:title>Test</mov:title>
      </mov:addMovieRequest>
   </soapenv:Body>
</soapenv:Envelope>
  • Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Client</faultcode>
         <faultstring xml:lang="en">Validation error</faultstring>
         <detail>
            <spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-complex-type.2.4.b: O conteúdo do elemento 'mov:addMovieRequest' não está completo. Era esperado um dos '{"http://www.abstract.com/movies-ws":category}'.</spring-ws:ValidationError>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Wrong Order Element Vaildation Example

  • Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mov="http://www.abstract.com/movies-ws">
   <soapenv:Header/>
   <soapenv:Body>
      <mov:addMovieRequest>
         <mov:category>Teste de Validação</mov:category>
         <mov:title>Teste</mov:title>
      </mov:addMovieRequest>
   </soapenv:Body>
</soapenv:Envelope>
  • Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Client</faultcode>
         <faultstring xml:lang="en">Validation error</faultstring>
         <detail>
            <spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-complex-type.2.4.a: Foi detectado um conteúdo inválido começando com o elemento 'mov:category'. Era esperado um dos '{"http://www.abstract.com/movies-ws":title}'.</spring-ws:ValidationError>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

JPA ERROR Example

  • Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mov="http://www.abstract.com/movies-ws">
   <soapenv:Header/>
   <soapenv:Body>
      <mov:addMovieRequest>
         <mov:title></mov:title>
         <mov:category></mov:category>
      </mov:addMovieRequest>
   </soapenv:Body>
</soapenv:Envelope>
  • Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring xml:lang="en">Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction</faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

That's All Folks!

Clone this wiki locally