Uploaded image for project: 'Axis-C++'
  1. Axis-C++
  2. AXISCPP-720

Returning Array of complex type is broken

    XMLWordPrintableJSON

Details

    Description

      There is a problem with the way arrays of complex types are being serialized before they are returned to the client from the web service. The problem went away when returned an object that contained the array (different classes where then generated for the array, see below). I think the problem is the way the stubs are generated for the case when a complex array is retured directly and not as part of a class.

      First I had the following interface on which I ran Java2WSDL and then WSDL2WS:

      public interface DatabaseInfoProvider {
      WsDatabaseObject[] getDatabaseObjects(String sUser, String sPassword, String connect, String objectTypes[], String searchString);
      }

      where

      public class WsDatabaseObject {
      public String sObjectType; // TABLE, VIEW, SP, SYNONYM
      public String sObjectName;
      public WsDatabaseColumn[] Columns;
      }

      where

      public class WsDatabaseColumn {
      public String name;
      public Boolean isPrimaryKey;
      }

      Here is the important part:
      The generated code for the array looks like:

      typedef struct WsDatabaseObject_ArrayTag
      {
      WsDatabaseObject** m_Array; // <-- BUG MAY BE HERE
      int m_Size;
      } WsDatabaseObject_Array;

      Then I change the interface to:

      public interface DatabaseInfoProvider {
      WsDatabaseInfo getDatabaseObjects(String sUser, String sPassword, String connect, String objectTypes[], String searchString);
      }

      where

      public class WsDatabaseInfo {
      public WsDatabaseObject[] dbInfo;
      }

      Note that the only difference is that I now return a class containing the array, instead of returning the array itself as was the case above.

      The code for the array now looks like:

      typedef struct WsDatabaseObject_ArrayTag
      {
      WsDatabaseObject* m_Array; // NOTE: just one * used
      int m_Size;
      } WsDatabaseObject_Array;

      The same thing is true for the nested array ( public WsDatabaseColumn[] Columns; ). I.e., in the code generated by from the first version of the interface defined in Java, WsDatabaseColumn_ArrayTag has WsDatabaseColumn** m_Array;, but in the second version it has WsDatabaseColumn* m_Array;.

      The first version crashes when serializing the result to be sent back to the client. The engine code seems to assume that the arrays are defined as T* m_Array and not T** m_Array.

      Attachments

        1. konga_database_infoprovider.wsdl
          4 kB
          Henrik Nordberg
        2. konga_database_infoprovider.1.2.wsdl
          4 kB
          Henrik Nordberg

        Activity

          People

            Unassigned Unassigned
            hnordberg Henrik Nordberg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: