Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-4859

Optional "Ignore Unexpected Elements" mode - allows for forward-compatible clients

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.2, 1.5.3, 1.6.0
    • Fix Version/s: 1.7.0
    • Component/s: codegen
    • Labels:
      None

      Description

      Problem: Service provider adds an optional element to the responses it sends, assuming client can handle, while client is unaware and has not (or cannot) retrieve updated WSDL and regenerate client. Axis2 client generated with ADB, cannot handle and throws an exception.

      Solution:
      Optional "Ignore Unexpected Elements" mode for wsdl2java using adb - allows for forward-compatible clients that can recover from unxpected elements in service responses.
      Based on the work in Issue 3037 - This patch is more up to date, is for both trunk and 1_5 branch, handles more scenarios, and will correctly parse the portion of the response after the unexpected element.

      To use, pass the "-Eiu" parameter to wsdl2java

      Handles the following scenarios:
      1) unexpected element in a xsd:choice, xsd:any, xsd:all
      2) appended unexpected element in a xsd:sequence.

      For xsd:sequence, the unexpected element, and subsequent elements within that sequence are not captured. If a service adds a new element within a sequence, it should be appended, as the generated client is strict with ordering, and can't differentiate an out-of-order sequence from an additional inserted element.

      1. names_v2_service.zip
        99 kB
        Ping Liu
      2. names_v2_client.zip
        59 kB
        Ping Liu
      3. names_v1_service.zip
        64 kB
        Ping Liu
      4. names_v1_client_with_xsl_change.zip
        43 kB
        Ping Liu
      5. names_v1_client.zip
        42 kB
        Ping Liu
      6. names_v2.wsdl
        3 kB
        Ping Liu
      7. iu.patch
        21 kB
        Ping Liu
      8. names_v2.response
        0.8 kB
        Dean Holdren
      9. names_v1.response
        0.6 kB
        Dean Holdren
      10. names_v1.wsdl
        3 kB
        Dean Holdren
      11. iu_trunk.patch
        20 kB
        Dean Holdren
      12. iu_1_5.patch
        20 kB
        Dean Holdren

        Issue Links

          Activity

          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Axis2 #3432 (See https://builds.apache.org/job/Axis2/3432/)
          AXIS2-5756: Document the -Eiu parameter on the WSDL2Java reference page. This change was part of the patch submitted by Dean Holdren for AXIS2-4859, but was never applied. (veithen: rev 1739348)

          • axis2/src/site/markdown/docs/reference.md
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Axis2 #3432 (See https://builds.apache.org/job/Axis2/3432/ ) AXIS2-5756 : Document the -Eiu parameter on the WSDL2Java reference page. This change was part of the patch submitted by Dean Holdren for AXIS2-4859 , but was never applied. (veithen: rev 1739348) axis2/src/site/markdown/docs/reference.md
          Hide
          united-expression AbdelRahman Sinno added a comment -

          This is a very crucial fix we need it, and we are not yet confident to use 1.7 SNAPSHOT.
          So, please someone answer the above question: if I use version 1.7 of axis2-adb-codegen and axis2-codegen jar (including this fix), does it work with the latest AXIS2 (1.6.3).

          Or, what else do you suggest to be able to ignore unexpected elements for NOW ?
          Since Apache CXF as not an option due to limitations it has with connection limits being common to the entire JVM.

          Show
          united-expression AbdelRahman Sinno added a comment - This is a very crucial fix we need it, and we are not yet confident to use 1.7 SNAPSHOT. So, please someone answer the above question: if I use version 1.7 of axis2-adb-codegen and axis2-codegen jar (including this fix), does it work with the latest AXIS2 (1.6.3). Or, what else do you suggest to be able to ignore unexpected elements for NOW ? Since Apache CXF as not an option due to limitations it has with connection limits being common to the entire JVM.
          Hide
          skmirch Sandeep Mirchandani added a comment -

          This patch is very useful. Can it be backported to 1.5? Also, if I was to take 1.7 versions of axis2-adb-codegen and axis2-codegen jar files only, and use the wsdl to generate java code, with the rest of the jars being at axis2 1.5.4, would that work?

          Show
          skmirch Sandeep Mirchandani added a comment - This patch is very useful. Can it be backported to 1.5? Also, if I was to take 1.7 versions of axis2-adb-codegen and axis2-codegen jar files only, and use the wsdl to generate java code, with the rest of the jars being at axis2 1.5.4, would that work?
          Hide
          cleber.zarate Cleber Zarate added a comment -

          We are coding against a service that is adding new values to enumerations. Is it possible to make this switch also allows for unexpected enumeration values?

          Show
          cleber.zarate Cleber Zarate added a comment - We are coding against a service that is adding new values to enumerations. Is it possible to make this switch also allows for unexpected enumeration values?
          Hide
          sagara Sagara Gunathunga added a comment -

          You have to use 1.7.0-SNAPSHOT versions of axis2-adb-codegen and axis2-codegen jar files.

          Show
          sagara Sagara Gunathunga added a comment - You have to use 1.7.0-SNAPSHOT versions of axis2-adb-codegen and axis2-codegen jar files.
          Hide
          rezer Ketil Flataker added a comment -

          I created the client based on v 1.5.4 in Eclipse, using wsdl2java utility in Eclipse (Webservice - Generate client), i choose ADB for databinding. Testing the client shows that it throws an "unexpected element found" when the service provider adds a new optional element in XSD for the response.

          Can you please advise me how to add this patch and generate a new client using Eclipse?

          Show
          rezer Ketil Flataker added a comment - I created the client based on v 1.5.4 in Eclipse, using wsdl2java utility in Eclipse (Webservice - Generate client), i choose ADB for databinding. Testing the client shows that it throws an "unexpected element found" when the service provider adds a new optional element in XSD for the response. Can you please advise me how to add this patch and generate a new client using Eclipse?
          Hide
          hudson Hudson added a comment -

          Integrated in Axis2 #1107 (See https://builds.apache.org/job/Axis2/1107/)
          Applied the patch for AXIS2-4859.

          sagara :
          Files :

          • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/CompilerOptions.java
          • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
          • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java
          • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
          • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl
          • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
          • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java
          • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
          Show
          hudson Hudson added a comment - Integrated in Axis2 #1107 (See https://builds.apache.org/job/Axis2/1107/ ) Applied the patch for AXIS2-4859 . sagara : Files : /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/CompilerOptions.java /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
          Hide
          sagara Sagara Gunathunga added a comment -

          Fixed in r1201993. Thanks a lot Dean and Ping for your contribution.

          Show
          sagara Sagara Gunathunga added a comment - Fixed in r1201993. Thanks a lot Dean and Ping for your contribution.
          Hide
          myapachejira Ping Liu added a comment -

          This is the update for this issue.

          1. the issue is still there, not fixed yet;

          2. there have been changes here and there since previous patch was provided. Therefore, new patch (iu.patch) has to be provided. Fortunately, the update is not significant;

          3. the patch works

          • allows client code to be re-generated with command option of "-Eiu"
          • the re-generated client code will ignore new elements instead of throwing exception on encountering new elements
          • test has been done for all cases that Dean iterated: xsd:sequence, xsd:choice, xsd:any, xsd:all

          4. following are the details

          • WSDLs:
            names_v1.wsdl (used the original attached names_v1.wsdl)
            names_v2.wsdl, a new WSDL based on names_v1.wsdl but contains extended elements (with all test types)
          • auto code generation command line arguments

          for service:
          wsdl2java -wv 1.1 -or -ss -sd -uri names_v1.wsdl -o names_v1_service
          wsdl2java -wv 1.1 -or -ss -sd -uri names_v2.wsdl -o names_v2_service

          for client:
          wsdl2java -wv 1.1 -or -sd -uri names_v1.wsdl -o names_v1_client
          wsdl2java -wv 1.1 -or -sd -uri names_v2.wsdl -o names_v2_client

          wsdl2java -wv 1.1 -or -sd -uri names_v1.wsdl -o names_v1_client_with_xsl_change (after applying the patch changes)

          • simple primitive implementations for demonstration purpose have been added to all services and clients
          • deployed names_v1_service, names_v2_service
          • verified names_v1_client works with names_v1_service, but fails with names_v2_service (this is to verify that the reported issue still exists)
          • verified names_v2_client works with names_v2_service (another way to verify the names_v2.wsdl is correct)
          • applied patch and generated names_v1_client_with_xsl_change
          • verified names_v1_client_with_xsl_change still works with names_v1_service but now also works with names_v2_service (this is to verify the patch works)
          • attachment:
            iu.patch
            names_v2.wsdl (names_v1.wsdl is the original attachment by Dean)
            names_v1_service.zip
            names_v1_client.zip
            names_v2_service.zip
            names_v2_client.zip
            names_v1_client_with_xsl_change.zip

          5. comment:

          • "-Eiu" command option is used for client re-generation only, this option is not for service generation (a scenario can be like this: upon a service call failed due to new element introduced on service, regenerate client with "-Eiu" option (this means having to swap in previous client implementation into the newly generated client code), the new client should work as before)
          • "-Eiu" should be used in caution as the option will make the code generator ignore all new elements regardless (it should be double checked to differentiate the case where new element is intended to be ignored and the potential error case where client code generation does not generate the element that is supposed to be generated)
          Show
          myapachejira Ping Liu added a comment - This is the update for this issue. 1. the issue is still there, not fixed yet; 2. there have been changes here and there since previous patch was provided. Therefore, new patch (iu.patch) has to be provided. Fortunately, the update is not significant; 3. the patch works allows client code to be re-generated with command option of "-Eiu" the re-generated client code will ignore new elements instead of throwing exception on encountering new elements test has been done for all cases that Dean iterated: xsd:sequence, xsd:choice, xsd:any, xsd:all 4. following are the details WSDLs: names_v1.wsdl (used the original attached names_v1.wsdl) names_v2.wsdl, a new WSDL based on names_v1.wsdl but contains extended elements (with all test types) auto code generation command line arguments for service: wsdl2java -wv 1.1 -or -ss -sd -uri names_v1.wsdl -o names_v1_service wsdl2java -wv 1.1 -or -ss -sd -uri names_v2.wsdl -o names_v2_service for client: wsdl2java -wv 1.1 -or -sd -uri names_v1.wsdl -o names_v1_client wsdl2java -wv 1.1 -or -sd -uri names_v2.wsdl -o names_v2_client wsdl2java -wv 1.1 -or -sd -uri names_v1.wsdl -o names_v1_client_with_xsl_change (after applying the patch changes) simple primitive implementations for demonstration purpose have been added to all services and clients deployed names_v1_service, names_v2_service verified names_v1_client works with names_v1_service, but fails with names_v2_service (this is to verify that the reported issue still exists) verified names_v2_client works with names_v2_service (another way to verify the names_v2.wsdl is correct) applied patch and generated names_v1_client_with_xsl_change verified names_v1_client_with_xsl_change still works with names_v1_service but now also works with names_v2_service (this is to verify the patch works) attachment: iu.patch names_v2.wsdl (names_v1.wsdl is the original attachment by Dean) names_v1_service.zip names_v1_client.zip names_v2_service.zip names_v2_client.zip names_v1_client_with_xsl_change.zip 5. comment: "-Eiu" command option is used for client re-generation only, this option is not for service generation (a scenario can be like this: upon a service call failed due to new element introduced on service, regenerate client with "-Eiu" option (this means having to swap in previous client implementation into the newly generated client code), the new client should work as before) "-Eiu" should be used in caution as the option will make the code generator ignore all new elements regardless (it should be double checked to differentiate the case where new element is intended to be ignored and the potential error case where client code generation does not generate the element that is supposed to be generated)
          Hide
          anishpyne Anish Pyne added a comment -

          Can we please have this patch in Axis 2 release as early as possible. This issue is causing a lot of pain for many people.

          Show
          anishpyne Anish Pyne added a comment - Can we please have this patch in Axis 2 release as early as possible. This issue is causing a lot of pain for many people.
          Hide
          deanholdren Dean Holdren added a comment -

          Files useful for testing (i.e. with SOAPUI mock service)

          WSDL: names_v1.wsdl
          Matching response: names_v1.response
          Response with unexpected elements: names_v2.response

          Show
          deanholdren Dean Holdren added a comment - Files useful for testing (i.e. with SOAPUI mock service) WSDL: names_v1.wsdl Matching response: names_v1.response Response with unexpected elements: names_v2.response
          Hide
          deanholdren Dean Holdren added a comment -

          Patches for the trunk and 1_5 branch to support "Ignore Unexpected" parameter (-Eiu) for wsdl2java

          Show
          deanholdren Dean Holdren added a comment - Patches for the trunk and 1_5 branch to support "Ignore Unexpected" parameter (-Eiu) for wsdl2java

            People

            • Assignee:
              myapachejira Ping Liu
              Reporter:
              deanholdren Dean Holdren
            • Votes:
              2 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development