You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Nuno Guerreiro <nv...@yahoo.com> on 2002/03/13 20:36:03 UTC
Problem with WSDL2JAVA (generated code doesn't compile)
I have the following element defined in a schema:
<xs:element name="confirmationCode" minOccurs="0">
<xs:complexType>
<xs:all>
<xs:element name="value" type="CodeValueType"
minOccurs="3" maxOccurs="3"/>
</xs:all>
</xs:complexType>
</xs:element>
The CodeValueType definition is as follows:
<xs:simpleType name="CodeValueType">
<xs:restriction base="xs:byte">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="9"/>
</xs:restriction>
</xs:simpleType>
The code generated by WSDL2JAVA (below) when I apply
it to a wsdl file which uses the confirmationCode
element contains an error in line 29 (method
setValue()), since it tries to compare a primitive
type to null. Does this happen with every primitive
type? I'm using the latest version of AXIS.
/**
* ConfirmationCode.java
*
* This file was auto-generated from WSDL
* by the Apache Axis Wsdl2java emitter.
*/
package pt.bcp.cidadebcp.webservices.system;
public class ConfirmationCode implements
java.io.Serializable {
private byte[] value;
public ConfirmationCode() {
}
public byte[] getValue() {
return value;
}
public void setValue(byte[] value) {
this.value = value;
}
public byte getValue(int i) {
return value[i];
}
public void setValue(int i, byte value) {
if (value == null ||
value.length <= i) {
byte[] a = new byte[i + 1];
if (value != null) {
for(int j=0; j<value.length; j++)
a[j] = value[j];
}
value = a;
}
value[i] = value;
}
public boolean equals(Object obj) {
// compare elements
ConfirmationCode other = (ConfirmationCode)
obj;
if (this == obj) return true;
if (! (obj instanceof ConfirmationCode))
return false;
return
((value==null && other.getValue()==null)
||
(value!=null &&
value.equals(other.getValue())));
}
}
Error produced:
Found 7 semantic errors compiling
"D:/projects/WebServices/generated/pt/bcp/cidadebcp/webservices/system/ConfirmationCode.java":
29. if (value == null ||
<----------->
*** Error: The type of the left-hand side expression,
"byte", is not compatible with the type of the
right-hand side expression, "null" (and vice-versa).
30. value.length <= i) {
<--->
*** Error: The type of this expression, "byte", is not
a valid reference type in this context.
32. if (value != null) {
<----------->
*** Error: The type of the left-hand side expression,
"byte", is not compatible with the type of the
right-hand side expression, "null" (and vice-versa).
33. for(int j=0; j<value.length;
j++)
<--->
*** Error: The type of this expression, "byte", is not
a valid reference type in this context.
34. a[j] = value[j];
<--->
*** Error: The type of this expression, "byte", is not
an array type.
36. value = a;
<------->
*** Error: The type of the left-hand side in this
assignment, "byte", is not compatible with the type of
the right-hand side expression, "byte[]".
38. value[i] = value;
<--->
*** Error: The type of this expression, "byte", is not
an array type.
------------------------
Many thanks for any help,
Nuno Guerreiro
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
Re: Problem with WSDL2JAVA (generated code doesn't compile)
Posted by Luis Novais <ln...@cidadebcp.pt>.
The solution is not giving the name "value" to the element, once the code
generation uses this name in the argument of a method.
Chears
Luis Novais
----- Original Message -----
From: "Nuno Guerreiro" <nv...@yahoo.com>
To: <ax...@xml.apache.org>
Sent: Wednesday, March 13, 2002 7:36 PM
Subject: Problem with WSDL2JAVA (generated code doesn't compile)
> I have the following element defined in a schema:
>
> <xs:element name="confirmationCode" minOccurs="0">
> <xs:complexType>
> <xs:all>
> <xs:element name="value" type="CodeValueType"
> minOccurs="3" maxOccurs="3"/>
> </xs:all>
> </xs:complexType>
> </xs:element>
>
> The CodeValueType definition is as follows:
>
> <xs:simpleType name="CodeValueType">
> <xs:restriction base="xs:byte">
> <xs:minInclusive value="0"/>
> <xs:maxInclusive value="9"/>
> </xs:restriction>
> </xs:simpleType>
>
>
> The code generated by WSDL2JAVA (below) when I apply
> it to a wsdl file which uses the confirmationCode
> element contains an error in line 29 (method
> setValue()), since it tries to compare a primitive
> type to null. Does this happen with every primitive
> type? I'm using the latest version of AXIS.
>
>
> /**
> * ConfirmationCode.java
> *
> * This file was auto-generated from WSDL
> * by the Apache Axis Wsdl2java emitter.
> */
>
> package pt.bcp.cidadebcp.webservices.system;
>
> public class ConfirmationCode implements
> java.io.Serializable {
> private byte[] value;
>
> public ConfirmationCode() {
> }
>
> public byte[] getValue() {
> return value;
> }
>
> public void setValue(byte[] value) {
> this.value = value;
> }
>
> public byte getValue(int i) {
> return value[i];
> }
>
> public void setValue(int i, byte value) {
> if (value == null ||
> value.length <= i) {
> byte[] a = new byte[i + 1];
> if (value != null) {
> for(int j=0; j<value.length; j++)
> a[j] = value[j];
> }
> value = a;
> }
> value[i] = value;
> }
>
> public boolean equals(Object obj) {
> // compare elements
> ConfirmationCode other = (ConfirmationCode)
> obj;
> if (this == obj) return true;
> if (! (obj instanceof ConfirmationCode))
> return false;
> return
> ((value==null && other.getValue()==null)
> ||
> (value!=null &&
> value.equals(other.getValue())));
> }
> }
>
>
> Error produced:
>
>
> Found 7 semantic errors compiling
>
"D:/projects/WebServices/generated/pt/bcp/cidadebcp/webservices/system/Confi
rmationCode.java":
>
> 29. if (value == null ||
> <----------->
> *** Error: The type of the left-hand side expression,
> "byte", is not compatible with the type of the
> right-hand side expression, "null" (and vice-versa).
>
>
> 30. value.length <= i) {
> <--->
> *** Error: The type of this expression, "byte", is not
> a valid reference type in this context.
>
>
> 32. if (value != null) {
> <----------->
> *** Error: The type of the left-hand side expression,
> "byte", is not compatible with the type of the
> right-hand side expression, "null" (and vice-versa).
>
>
> 33. for(int j=0; j<value.length;
> j++)
> <--->
> *** Error: The type of this expression, "byte", is not
> a valid reference type in this context.
>
>
> 34. a[j] = value[j];
> <--->
> *** Error: The type of this expression, "byte", is not
> an array type.
>
>
> 36. value = a;
> <------->
> *** Error: The type of the left-hand side in this
> assignment, "byte", is not compatible with the type of
> the right-hand side expression, "byte[]".
>
>
> 38. value[i] = value;
> <--->
> *** Error: The type of this expression, "byte", is not
> an array type.
>
>
>
>
> ------------------------
>
> Many thanks for any help,
>
>
>
> Nuno Guerreiro
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Try FREE Yahoo! Mail - the world's greatest free email!
> http://mail.yahoo.com/