[ 
https://issues.apache.org/jira/browse/AXIS2-4108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12646836#action_12646836
 ] 

samlemarnais edited comment on AXIS2-4108 at 11/12/08 1:35 AM:
---------------------------------------------------------

Hi, 
When using the "uwc" ADB parameter (-Euwc wsdl2java parameter), the generated 
source code loose its Java1.4 compatibility !!!
The reason is that the SAOP decoder is a "fake" ;)
It convert the String to an int and then "automatically" cast it to an Integer 
(Java5 new functionnality)...
Moreover, what if the String is null or empty (nillable element) ?

This is the ****************** JAVA 1.4 NON COMPATIBLE ********************** 
generated code is here (implicit cast from int to Integer) :

--------------------------------------------------------------------------
                                if (reader.isStartElement() && new 
javax.xml.namespace.QName("", "fundId").equals(reader.getName()))
                                {
                                        
                                        java.lang.String content = 
reader.getElementText();
                                        
                                        
object.setFundId(org.apache.axis2.databinding.utils.ConverterUtil.convertToInt(content));
     <------- implicit conversion. Function signature : public void 
setFundId(java.lang.Integer param)
                                        
                                        reader.next();
                                        
                                } // End of if for expected property start 
element
--------------------------------------------------------------------------

Work Arround :
I think that the method 
"org.apache.axis2.databinding.utils.ConverterUtil.convertToInt" should be 
replaced by "org.apache.axis2.databinding.utils.ConverterUtil.convertToInteger".

I didn't try other simple types (boolean, etc.) I think the same problem 
occurs...

      was (Author: samlemarnais):
    Hi, 
When using the "uwc" ADB parameter (-Euwc wsdl2java parameter), the generated 
source code loose its Java1.4 compatibility !!!
The reason is that the SAOP decoder is a "fake" ;)
It convert the String to an int and then "automatically" cast it to an Integer 
(Java5 new functionnality)...
Moreover, what if the String is null or empty (nillable element) ?

This is the ****************** JAVA 1.4 NON COMPATIBLE ********************** 
generated code is here (implicit cast from int to Integer) :

--------------------------------------------------------------------------
                                if (reader.isStartElement() && new 
javax.xml.namespace.QName("", "fundId").equals(reader.getName()))
                                {
                                        
                                        java.lang.String content = 
reader.getElementText();
                                        
                                        
object.setFundId(org.apache.axis2.databinding.utils.ConverterUtil.convertToInt(content));
     <------- implicit conversion. Function signature : public void 
setFundId(java.lang.Integer param)
                                        
                                        reader.next();
                                        
                                } // End of if for expected property start 
element
--------------------------------------------------------------------------

Axis2 is officially known to be java1.4 compatible isn't it ?
  
> WSDL2Java: minOccurs="0" on primitive types doesn't work properly
> -----------------------------------------------------------------
>
>                 Key: AXIS2-4108
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4108
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.4.1
>         Environment: Windows XP
> Eclipse Version: 3.3.2 Build id: M20080221-1800
> Apache Axis2 1.4.1 build  (13-08-2008)
>            Reporter: Samuel
>            Assignee: Amila Chinthaka Suriarachchi
>            Priority: Critical
>
> When I'm generating Java classes with wsdl2java (using eclipse WTP plugin) 
> from this part of xsd :
> -----------------------------------------------------------------------------
>       <xsd:complexType name="Frids_GetFundInType">
>               <xsd:sequence>
>                       <xsd:element maxOccurs="1" minOccurs="0"
>                               name="fund_id"
>                               type="xsd:int">
>                       </xsd:element>
>               </xsd:sequence>
>       </xsd:complexType>
> -----------------------------------------------------------------------------
> I'm getting an int variable that can not be set to null.
> In the class "Frids_GetFundInType" (generated by wsdl2java), I see this :
> -----------------------------------------------------------------------------
>       /**
>        * Auto generated getter method
>        * 
>        * @return int
>        */
>       public int getId() {
>               return localId;
>       }
>       /**
>        * Auto generated setter method
>        * 
>        * @param param
>        *            Id
>        */
>       public void setId(int param) {
>               // setting primitive attribute tracker to true
>               if (param == java.lang.Integer.MIN_VALUE) {
>                       localIdTracker = false;
>               } else {
>                       localIdTracker = true;
>               }
>               this.localId = param;
>       }
> -----------------------------------------------------------------------------
> So, if I correctly understand the code :
> - If a client set a value equal to "Integer.MIN_VALUE", my server will think 
> that he didn't set this field.
> - I can not check if this field is null or not : 
> -----------------------------------------------------------------------------
> I can not write if (myVariable.fund_id == null){
>  then...
> }
> -----------------------------------------------------------------------------
> as an int can not be null, and the xxxTracker variable is protected...
> I seen a similar bug marked as fixed but I've download the last release 2 
> days ago and this samples are from this version...
> If it's really fixed, can you tell me how can I have the good version (and 
> its number) and what do I have to do (is it automatically corrected ?)
> Thanks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to