This content has been marked as final.
Show 3 replies
-
1. Re: JBossWS tools functionality matching wscompile tool
anil.saldhana May 26, 2005 12:25 PM (in response to anil.saldhana)Additional annoyance with regard to Simple Types with enumeration:
Schema To Java Type<!--Define a simple type, an enumerated type--> <xsd:simpleType name="USMidwest"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="IN"/> <xsd:enumeration value="IL"/> <xsd:enumeration value="OH"/> </xsd:restriction> </xsd:simpleType>
Now look at the Java Type that is generated by wscompile for the above schema type.// This class was generated by the JAXRPC SI, do not edit. // Contents subject to change without notice. // JAX-RPC Standard Implementation (1.1.2_01, build R40) // Generated source version: 1.1.2 package org.jboss.ws.types; import java.util.Map; import java.util.HashMap; public class USMidwest { private java.lang.String value; private static Map valueMap = new HashMap(); public static final String _INString = "IN"; public static final String _ILString = "IL"; public static final String _OHString = "OH"; public static final java.lang.String _IN = new java.lang.String(_INString); public static final java.lang.String _IL = new java.lang.String(_ILString); public static final java.lang.String _OH = new java.lang.String(_OHString); public static final USMidwest IN = new USMidwest(_IN); public static final USMidwest IL = new USMidwest(_IL); public static final USMidwest OH = new USMidwest(_OH); protected USMidwest(java.lang.String value) { this.value = value; valueMap.put(this.toString(), this); } public java.lang.String getValue() { return value; } public static USMidwest fromValue(java.lang.String value) throws java.lang.IllegalStateException { if (IN.value.equals(value)) { return IN; } else if (IL.value.equals(value)) { return IL; } else if (OH.value.equals(value)) { return OH; } throw new IllegalArgumentException(); } public static USMidwest fromString(String value) throws java.lang.IllegalStateException { USMidwest ret = (USMidwest)valueMap.get(value); if (ret != null) { return ret; } if (value.equals(_INString)) { return IN; } else if (value.equals(_ILString)) { return IL; } else if (value.equals(_OHString)) { return OH; } throw new IllegalArgumentException(); } public String toString() { return value.toString(); } private Object readResolve() throws java.io.ObjectStreamException { return fromValue(getValue()); } public boolean equals(Object obj) { if (!(obj instanceof USMidwest)) { return false; } return ((USMidwest)obj).value.equals(value); } public int hashCode() { return value.hashCode(); } }
Java to schema
Let us write a simple SEI that will use this java class called USMidwest generated by wscompile./* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.ws.jbws_204.sei; import org.jboss.test.ws.jbws_204.wscompile.simpletypes.USMidwest; import java.rmi.Remote; import java.rmi.RemoteException; /** * JBWS -204 : Java to XSDSchema comprehensive test collection * The SEI that tests enumerated types in Simple Types * @author <mailto:Anil.Saldhana@jboss.org>Anil Saldhana * @since May 25, 2005 */ public interface SimpleTypeEnumerationSEI extends Remote { public void testEnumeration( USMidwest midwest) throws RemoteException; }
Now when I feed this SEI into wscompile to generate a wsdl so that I can have a look at the schema, I get errors. (Please check my reply for the errors). -
2. Re: JBossWS tools functionality matching wscompile tool
anil.saldhana May 26, 2005 12:30 PM (in response to anil.saldhana)Here is the error that it throws:
error: class org.jboss.test.ws.jbws_204.wscompile.simpletypes.USMidwest does not have a public accessible empty constructor
Ok, wscompile now found out that the java class that it generated previously is not acceptable as a Jaxrpc value type.
For testing purposes, I gave a dummy public constructor to the class USMidwest, I get the following error:error: invalid type for JAX-RPC structure: org.jboss.test.ws.jbws_204.wscompile.simpletypes.USMidwest
So basically, wscompile approach to XSD Simple Types with enumeration is broken. -
3. Re: JBossWS tools functionality matching wscompile tool
anil.saldhana Jul 27, 2005 5:20 PM (in response to anil.saldhana)When tools generates Java Types with annotations, we will use JDK5 enums to solve this issue. When using JDK1.4, I will retain the current implementation of generating xsd -> Java as shown in my previous post. But the user will not be able to reuse the Java Type (that contains JDK1.4 style enumerations) to be converted into a xsd simple type with enumeration.