3 Replies Latest reply on Sep 11, 2008 5:13 PM by Anuradha Rahurkar

    Validation of input

    Jasper Siepkes Newbie


      I've got a rather basic (ie. noob) question about the validation of data send over to an Webservices endpoint.

      What is the best way for an JSR-181 endpoint to validate incomming data on length, pattern, etc. before inserting it in a DB or something ? Is there anyway to set the pattern, minLength or maxLength constraints in the generated WSDL (Is it even allowed to use XML schema constraints in an WSDL)?

      Or do you manually have to check the POJO's and throw a custom error if the validation fails (ie. use the WSDL "fault message")?


        • 1. Re: Validation of input
          Heiko Braun Master

          XML schema allows you todo that.

          • 3. Re: Validation of input
            Anuradha Rahurkar Newbie

            I had a similar question:
            I have a WSDL operation which is based on a XML schema with the following info:

            <xs:element name="CheckInDate">
            <xs:documentation>CheckInDate: YYMMDD</xs:documentation>
            <xs:restriction base="xs:string">
            <xs:length value="6"/>
            <xs:pattern value="\d\d\d\d\d\d"/>

            <xs:element name="FolioID">
            <xs:restriction base="xs:string">
            <xs:minLength value="0"/>
            <xs:maxLength value="25"/>

            Couple of questions around this schema:
            1. Does JBossWS framework understand the xml schema constraints of xs:minLength, xs:maxLength and xs:pattern, if specified?

            2. What kind of error (Soap or otherwise) does the JBossWS framework throw or report to the WS-Client, if minLength, maxLength and pattern constraints are violated.?

            3. If not, do I need to do a validation around these constraints in my code and throw a wsdl 'validation error' fault.

            Thanks in Advance!