XMLBeans
  1. XMLBeans
  2. XMLBEANS-426

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

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: Version 2.4
    • Fix Version/s: None
    • Component/s: Binding
    • Labels:
      None
    • 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.

      Description

      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.

        Issue Links

          Activity

          Pundarikakshaiah Ganduri created issue -
          Pundarikakshaiah Ganduri made changes -
          Field Original Value New Value
          Original Estimate 504h [ 1814400 ]
          Remaining Estimate 504h [ 1814400 ]
          Priority Major [ 3 ] Blocker [ 1 ]
          Janick Reynders made changes -
          Link This issue duplicates XMLBEANS-220 [ XMLBEANS-220 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Pundarikakshaiah Ganduri
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 504h
                504h
                Remaining:
                Remaining Estimate - 504h
                504h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development