Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc]Custom annotation to skip null values to preserve Backward Compatibility. #155

Open
hasinidilanka opened this issue Feb 15, 2019 · 0 comments

Comments

@hasinidilanka
Copy link
Contributor

Description:
Suppose a new attribute is added to an Admin Service (WSDL) and the corresponding stub is changed. Then the existing clients that have not regenerated the stub will get an error "Unexpected Subelement" when trying to access a service that will return the new attribute.

To overcome this compatibility issue I have introduced a new field type annotation "IgnoreNullElement" in Axis2 and a configuration property "forceIncludeNullElements" in axis2.xml file(IS-Home/repository/conf/axis2/axis2.xml).

PR - 7c7ce54

There are two main use cases of this annotation.

  1. When property value = null, @IgnoreNullElement is set to the property and forceIncludeNullElements configuration is either not set or false
  • Then the property will be skipped when creating the response
  1. When property value = null, @IgnoreNullElement is set to the property and forceIncludeNullElements configuration is true
  • Then the property will not be skipped when creating the response

How to use the annotation.

Add the annotation @IgnoreNullElement before the property declaration.

Eg:

         import org.apache.axis2.databinding.annotation.IgnoreNullElement;
         @IgnoreNullElement
         private String propertyName;

Then add the below parameter and configure it to true to not skip properties that are null

      `<parameter name="forceIncludeNullElements">true</parameter>`

Or configure the parameter to false to skip the properties that are null. If the parameter is not set in the axis2.xml it will be considered as the parameter is set to false.

       `<parameter name="forceIncludeNullElements">false</parameter>`

This annotation and the property in the axis2.xml should be documented for developers use.
Affected Product Version:
Asix2 versions: master, 1.6.1-wso2v28, 1.6.1-wso2v20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant