You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Balaji Sengeni (JIRA)" <ji...@apache.org> on 2012/10/23 18:17:11 UTC

[jira] [Created] (CXF-4597) CXF - jaxws - schema validation for nillable false

Balaji Sengeni created CXF-4597:
-----------------------------------

             Summary: CXF - jaxws - schema validation for nillable false
                 Key: CXF-4597
                 URL: https://issues.apache.org/jira/browse/CXF-4597
             Project: CXF
          Issue Type: Bug
          Components: JAXB Databinding
    Affects Versions: 2.6
         Environment: Tomcat web server
            Reporter: Balaji Sengeni
            Priority: Blocker


Hi ,

 I apologize, if I have chosen wrong issue type.

 I use contract first web service where xsd is defined in external file. 
 [by default, nillable is false if we haven't mentioned for elements in xsd]

 I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.

 But when the user sends empty tag, my web service accepts that value. 

 Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?

 

 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13493218#comment-13493218 ] 

Daniel Kulp commented on CXF-4597:
----------------------------------


{code:xml}
<lastname></lastname>
{code}

That doesn't represent a "null" string, that's an empty string.  Thus, the message IS valid as a string of length 0 is certainly less then the maxLength of 100.


                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Balaji Sengeni (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13493808#comment-13493808 ] 

Balaji Sengeni commented on CXF-4597:
-------------------------------------

Hi Daniel,

  I tried setting the minOccurs="1" as :

    <xsd:element name="firstnames" maxOccurs="1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

even then ws accepts empty tag as <firstnames/>, is there a way to do minor changes and have empty string validation? i.e., web  service should throw xsd validation exception if there is any empty tag in the payload (not to accept empty tag at any level). xml payload should have tag only if it has text value inside it.

Thanks,
 Balaji
                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13482929#comment-13482929 ] 

Freeman Fang commented on CXF-4597:
-----------------------------------

Hi,

Are you sure you're using CXF codegen maven plugin?

The plugin name jaxws-maven-plugin indicate it's from metro.

In cxf we use cxf-codegen-plugin

Freeman
                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Balaji Sengeni (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Balaji Sengeni updated CXF-4597:
--------------------------------


It looks like a bug, please can you provide me a workaround reference using CXF Interceptor for nillable false XSD validation.


Regards,
 Balaji  
                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-4597.
------------------------------

       Resolution: Invalid
    Fix Version/s: Invalid


This is definitely more of a question for the users@cxf.apache.org list (or jax-ws lists if not using cxf).    

To basically answer the question though:  if there isn't a minOccurs on the schema, then an empty element is valid input.   You would need to write custom code to possibly validate the incoming data.   A CXF interceptor could do that fairly easily.   

                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Reopened] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Balaji Sengeni (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Balaji Sengeni reopened CXF-4597:
---------------------------------

    
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Santhosh Manickam (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13488765#comment-13488765 ] 

Santhosh Manickam commented on CXF-4597:
----------------------------------------

minOccurs is not mentioned, by default minOccurs=1, here is XMLElement specification http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlElement.html

I think this is bug, that needs to be fixed.
                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-4597.
------------------------------

    Resolution: Not A Problem
    
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Santhosh Manickam (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13488765#comment-13488765 ] 

Santhosh Manickam edited comment on CXF-4597 at 11/1/12 3:33 PM:
-----------------------------------------------------------------

if minOccurs is not mentioned, by default minOccurs=1, here is XMLElement specification http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlElement.html

I think this is bug, that needs to be fixed.
                
      was (Author: smanickam):
    minOccurs is not mentioned, by default minOccurs=1, here is XMLElement specification http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlElement.html

I think this is bug, that needs to be fixed.
                  
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Balaji Sengeni (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13493210#comment-13493210 ] 

Balaji Sengeni commented on CXF-4597:
-------------------------------------

Hi Freeman,

 I have tried using the 'cxf-codegen-plugin' for wsdl2java goal, even then nillable attribute is missing for the generated java class.

   i.e, actually @XmlElement(required = true) but not create as @XmlElement(required = true, nillable = false) for all the elements in the xsd where nillable is not defined explicitly in schema. [since nillable is false by default as per xsd]

But JAXB parser accepts empty xml element as shown in example below.

XSD fragment :
------------  

    <xsd:complexType name="person">
        <xsd:sequence>
            <xsd:element name="title" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="firstnames">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="100"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="lastname">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="100"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="date-of-birth" type="dateTimeZ"/>
        </xsd:sequence>
    </xsd:complexType>

for this xsd included in wsdl below xml fragment is allowed by the cxf ws with schema validation enabled.

                         <person>
                            <title>Mr</title>
                            <firstnames>Freeman</firstnames>
                            <lastname></lastname>
                            <date-of-birth>19631015000000Z</date-of-birth>
                        </person>

where '<lastname>' element is null which is valid for java string datatype. But as per schema, nillable is false(default for all elements in xsd) which shouldn't accept this value and throw xsd validation failure exception but cxf doesn't throw (JAXB skips this validation).

Hi Daniel,

  I got your point of - user defined CXF interceptor configured before/after default XSD validation phase and do explicit nillable validation for each element which I feel little heavy(since I have min. 200 + elements in payload). Please can you provide me a reference / example for it.

Thanks & Regards,
  Balaji
                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4597) CXF - jaxws - schema validation for nillable false

Posted by "Jason Pell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13493860#comment-13493860 ] 

Jason Pell commented on CXF-4597:
---------------------------------

An empty string is still a string, so minOccurs=1 would still be satisfied.  However what you could do is <xsd:minLength value="1"/>

Obviously you can't do that at the JAXB level, but at Schema level it would certainly force you to enter at least one character for it to be considered a legal value.

I have created an mailing list post to provide some additional input that you may find of use.

http://cxf.547215.n5.nabble.com/Extended-JAXB-facet-validations-td5718194.html

                
> CXF - jaxws - schema validation for nillable false
> --------------------------------------------------
>
>                 Key: CXF-4597
>                 URL: https://issues.apache.org/jira/browse/CXF-4597
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.6
>         Environment: Tomcat web server
>            Reporter: Balaji Sengeni
>            Priority: Blocker
>             Fix For: Invalid
>
>
> Hi ,
>  I apologize, if I have chosen wrong issue type.
>  I use contract first web service where xsd is defined in external file. 
>  [by default, nillable is false if we haven't mentioned for elements in xsd]
>  I used jaxws-maven-plugin to import java classes from wsdl. I noticed that nillable attribute is missing for @XmlElement(required = true) [java data type string]. I assume, its the default behaviour, so Jaxb will treat those element as nillable false.
>  But when the user sends empty tag, my web service accepts that value. 
>  Without touching the xsd (setting minLength for the string), is there a easy way to do non empty string validation?
>  
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira