You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Alain Andrieux <aa...@hotmail.com> on 2003/10/10 19:41:32 UTC
WSDL2Java: XSD elements of same names --> compilation error
Hi,
I think I *might* have found a WSDL2Java bug. I looked at the Bugzilla page
and
could not find an equivalent, but I'd rather check with the dev-list first.
Axis version: 1.1 1541 June 18 2003
Summary of the problem: multiple <any> elements or multiple elements
declared
with the same name are translated by
WSDL2Java
into multiple Java fields of the same
names,
resulting in Java compilation errors.
I have a complex type defined this way:
<xs:complexType name="PolicyAttachmentType">
<xs:sequence>
<xs:element ref="wsp:AppliesTo"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
<xs:choice maxOccurs="unbounded">
<xs:element ref="wsp:Policy"/>
<xs:element ref="wsp:PolicyReference"/>
</xs:choice>
<xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##any" processContents="lax"/>
</xs:complexType>
It's from the WS-Policy spec BTW. I personally don't like too much the
top-level
apposition of the AppliesTo element and the first <any>, but this is a valid
Schema
complex type. The content model is not ambiguous (the top-level group is a
<sequence> not a <all> or <choice>; ##other is used; no element in the
<choice>
is optional and both are from the target namespace).
Unfortunately WSDL2Java doesn't seem to handle the multiple <any>.
In fact, it creates only one Java field in the generated Java class (this
behavior also occurs for a named element repeated more than once BTW),
resulting in compilation errors:
[javac] [...]/build/stubs/org/xmlsoap/policy/PolicyAttachmentType.java:15:
_any is already defined in org.xmlsoap.policy.PolicyAttachmentType
[javac] private org.apache.axis.message.MessageElement [] _any;
[javac] ^
[javac] [...]/build/stubs/org/xmlsoap/policy/PolicyAttachmentType.java:52:
get_any() is already defined in org.xmlsoap.policy.PolicyAttachmentType
[javac] public org.apache.axis.message.MessageElement [] get_any() {
So:
1) is there a workaround other than modifying the schema type?
(most important question)
2) is this limitation known? If so, is it planned to be fixed at some
point or remain a limitation of the schema compiler?
3) am I missing something here?
Thanks a lot in anticipation
Alain Andrieux