Generated XML from an XSD contains xsi:nil="true" attribute for an optional 
(minOccurs="0") SimpleType element causing issue while processing of SOAP 
request
-------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: XMLBEANS-426
                 URL: https://issues.apache.org/jira/browse/XMLBEANS-426
             Project: XMLBeans
          Issue Type: Bug
          Components: Binding
    Affects Versions: Version 2.4 
         Environment: Windows OS, WAS 6.1,  xbean-2.4.0. AXIS2 with XMLBeans 
binding for SOAP requests at client side. AXIS2 with ADB bindings at server 
side.
            Reporter: Pundarikakshaiah Ganduri


In my project we are using AXIS2 along with XMLBeans binding to generate the 
payload classes for the web services. The XSD has an element like <xs:element 
name="LoanPurposeDesc" type="xs:string" minOccurs="0" /> 

The generated SOAP request xml contains the empty element for this field 
"LoanPurposeDesc" with a xsi:nil="true" attribute as shown below. 
<mtv1:LoanPurposeDesc xsi:nil="true" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

This is causing the parsing error message on the receiving end of the SOAP 
request. 
Due to this the parser is throwing the error like for the element that is of 
SimpleType the only expected attribute is its namespace declaration. 

For time being to avoid this issue I have modified following way:
Changed XSD to modify the defintion of that element as:
<xs:element name="LoanPurposeDesc" type="xs:string" minOccurs="0" 
nillable="true"/>
And changed the printSetterImpls() method of 
org.apache.xmlbeans.impl.schema.SchemaTypeCodePrinter class so that it calls 
the unSet methd of a property if the property value is coming as null as below:

                        if (nillable
                                        && optional
                                        && !(javaType >= 
SchemaProperty.JAVA_FIRST_PRIMITIVE && javaType <= 
SchemaProperty.JAVA_LAST_PRIMITIVE)) {
                                emit("if ("+safeVarName+" == null){");
                                emit("\tunset" + propertyName + "();");
                                emit("return;");
                                emit("}");
                                
                        }

Please provide a resolution for this or confirm if we can use the changes I 
have specified.

-- 
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: dev-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: dev-h...@xmlbeans.apache.org

Reply via email to