Hi,
I've run into a problem with enumerations since moving from axis-1.2beta to axis-1.2rc1. With axis-1.2beta, enumerations with string values were generated with the strings in the namespace "http://www.w3.org/2001/XMLSchema". With axis-1.2rc1, enumerations with string values were generated with the strings in the namespace "http://schemas.xmlsoap.org/soap/encoding/".
So for example, the following enumeration type mapping in WSDD generates different WSDL for axis rc1 and beta:
<typeMapping
xmlns:ns="urn:wsdl.test"
qname="ns:role"
type="java:Role"
serializer="org.apache.axis.encoding.ser.EnumSerializerFactory"
deserializer="org.apache.axis.encoding.ser.EnumDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
xmlns:ns="urn:wsdl.test"
qname="ns:role"
type="java:Role"
serializer="org.apache.axis.encoding.ser.EnumSerializerFactory"
deserializer="org.apache.axis.encoding.ser.EnumDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
In beta the generated WSDL looks like:
<simpleType name="role">
<restriction base="xsd:string">
<enumeration value="Admin"/>
<enumeration value="user"/>
</restriction>
</simpleType>
In rc1 the generated WSDL looks like:
<simpleType name="role">
<restriction base="soapenc:string">
<enumeration value="Admin"/>
<enumeration value="user"/>
</restriction>
</simpleType>
The problem comes when I generated client stubs from the WSDL. The client stubs for the WSDL with the "xsd" strings get generated with no problems. A Role enumeration is created as I'd expect. However, the client stubs for the WSDL with the "soapenc" strings do not have enumerated types. They get generated as just string properties on the parent object rather than enumerations.
The problem seems to be that the client generator only considers a type an enumeration if it is in the "http://www.w3.org/*/XMLSchema" namespace (and is a simple type). The org.apache.axis.wsdl.toJava.Utils class has a getEnumerationBaseAndValues method that seems to be the problem. The code in getEnumerationBaseAndValues reads:
if (baseEType != null) {
String javaName = baseEType.getName();
if (javaName.equals("boolean")
|| !SchemaUtils.isSimpleSchemaType(
baseEType.getQName())) {
baseEType = null;
}
}
String javaName = baseEType.getName();
if (javaName.equals("boolean")
|| !SchemaUtils.isSimpleSchemaType(
baseEType.getQName())) {
baseEType = null;
}
}
I am guessing it should check to see if the qname is a simple schema type OR a simple soap encoding type. I tried to test my theory by changing org.apache.axis.wsdl.toJava.Utils to:
if (baseEType != null) {
String javaName = baseEType.getName();
if (javaName.equals("boolean")
|| (!SchemaUtils.isSimpleSchemaType(baseEType.getQName()) && !isSoapEncodedString(baseEType.getQName()))) {
baseEType = null;
}
}
String javaName = baseEType.getName();
if (javaName.equals("boolean")
|| (!SchemaUtils.isSimpleSchemaType(baseEType.getQName()) && !isSoapEncodedString(baseEType.getQName()))) {
baseEType = null;
}
}
with the methods defined as:
private static boolean isSoapEncodedString(QName qName) {
if ((qName == null) || !isSoapXSD(qName.getNamespaceURI())) {
return false;
}
private static boolean isSoapEncodedString(QName qName) {
if ((qName == null) || !isSoapXSD(qName.getNamespaceURI())) {
return false;
}
return "string".equals(qName.getLocalPart());
}
}
private static boolean isSoapXSD(String namespace) {
return "http://schemas.xmlsoap.org/soap/encoding/".equals(namespace);
}
return "http://schemas.xmlsoap.org/soap/encoding/".equals(namespace);
}
Using my modified jar with that change, the stubs where generated as I expected.
So my question is whether this is a known bug (I couldn't find anything in Jira)? If not, am I doing something wrong? It seems that if I use java2wsdl to generate wsdl then wsdl2java to generate client stubs I ought to get the enumeration properties rather than just string properties.
Thanks in advance for any help,
Brian
Do you Yahoo!?
Discover all that’s new in My Yahoo!