Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8305

WSDL2Java generates java code that won't compile for array of byte arrays

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 3.3.6
    • Fix Version/s: None
    • Component/s: Tooling
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      I am using a wsdl snippet that looks like the following:

                 <xsd:complexType name="CACertificateLDAPGetResult">
                      <xsd:annotation>
                          <xsd:documentation>
                              Defines the results of a caCertificateLDAPGet operation
                          </xsd:documentation>
                      </xsd:annotation>
                      <xsd:sequence>
                          <xsd:element name="Binary" type="xsd:boolean" nillable="true">
                              <xsd:annotation>
                                  <xsd:documentation>
                                      Indicates whether the returns attribute is string data or binary data.
                                      True if the attribute is binary.
                                  </xsd:documentation>
                              </xsd:annotation>
                          </xsd:element>
                          <xsd:element name="StringAttribute" maxOccurs="unbounded" minOccurs="0" type="xsd:string" nillable="true" >
                              <xsd:annotation>
                                  <xsd:documentation>
                                      A list of the strings found at a string attribute.
                                  </xsd:documentation>
                              </xsd:annotation>
                          </xsd:element>
                          <xsd:element name="BinaryAttribute" maxOccurs="unbounded" minOccurs="0" type="xsd:base64Binary" 
                                       nillable="true" >
                              <xsd:annotation>
                                  <xsd:documentation>
                                      A list of the base64 encoded data found at a binary attribute.
                                  </xsd:documentation>
                              </xsd:annotation>
                          </xsd:element>                    
                      </xsd:sequence>
                  </xsd:complexType>
      

      In is the BinaryAttribute above that is of interest.

      When this gets compiled using WSDL2Java and Java 8 with collectionType="indexed", the following code snipped is produced.

       

          /**
           * 
           * 
           * @param values
           *     allowed objects are
           *     byte[]
           */
          public void setBinaryAttribute(byte[][] values) {
              int len = values.length;
              this.binaryAttribute = ((byte[][]) new byte[][len] );
              for (int i = 0; (i<len); i ++) {
                  this.binaryAttribute[i] = ((byte[]) values[i]);
              }
          }
      
      

      Clearly, this is invalid Java since you need to set len on the first dimension of the array, not the second.

      Java can't compile the code generated by WSDL2Java so that's the end of things.

      If you know of any work-around (other than not using collectionType="indexed", please let me know. Thanks!

        Attachments

        1. test.zip
          3 kB
          Steve Armstrong

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                starmstr Steve Armstrong
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: