[Axis2] Fixed value causes Exception for non fixed values in ADB generated code

Frederik Hansen <[email protected]>
Newsgroups gmane.text.xml.axis.user
Message-ID <[email protected]>
Hi

I'm using Axis 1.7.1 and found an issue using fixed values in WDSL and the 
ADB Codegenerator.

Basically when one fixed value/attribute exists, all attributes are treated 
as fixed attributes. This means, when setting the value on a non-fixed 
attribute, it set be seen as null (but set) and causing an exception.

I've attached a simplified WSDL, the generate java files, one with the 
fixed value in place, and one without, and also a diff showing the issue 
(the missing line with "this.localPersonId = param;").

I've looked in the ADB Codegen code, and IMHO the issue seems to be in 
SchemaCompiler where the code says:

            // register the fixed value if present
            if (xsElt.getFixedValue() != null) {
                metainf.registerDefaultValue(xsElt.getQName(), 
xsElt.getFixedValue());
                metainf.setFixed(true);
            }

The setFixed seems to be too broad, and maybe it can be changed into 
something following the registerNillableQName-flow, e.g. 
registerFixedQName(xsElt.getQName()).

Just to test, I've also tried version 1.7.0 and 1.6.4, there the same issue 
exists.

Hope this make sense.

Regards,
Frederik Hansen


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
With-FixedValueSampleServiceStub.java (text/x-java, 130.9 KB) - not displayed
Without-FixedValueSampleServiceStub.java (text/x-java, 130.9 KB) - not displayed
Diff.txt (text/plain, 1.3 KB)
--- a/FixedValueSampleServiceStub
+++ b/FixedValueSampleServiceStub
@@ -154,8 +154,7 @@
               org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
       org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
 
-      java.lang.Object object = fromOM(
-              _returnEnv.getBody().getFirstElement(),
+      java.lang.Object object = fromOM(_returnEnv.getBody().getFirstElement(),
               localhost.fixedvaluesample.FixedValueSampleServiceStub.FixedValueSample.class);
 
       return (localhost.fixedvaluesample.FixedValueSampleServiceStub.FixedValueSample) object;
@@ -2734,14 +2733,13 @@
     public void setPersonId(PersonId_type1 param) {
       localPersonIdTracker = param != null;
 
-      this.localPersonId = param;
-
     }
 
     /**
      * field for DateTimeTagFormat This was an Attribute!
      */
-    protected java.lang.String localDateTimeTagFormat;
+    protected java.lang.String localDateTimeTagFormat
+            = org.apache.axis2.databinding.utils.ConverterUtil.convertToString("xsd:strict");
 
     /**
      * Auto generated getter method
@@ -2759,8 +2757,6 @@
      */
     public void setDateTimeTagFormat(java.lang.String param) {
 
-      this.localDateTimeTagFormat = param;
-
     }
 
     /**
FixedValueSample.wsdl (application/octet-stream, 6.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.