6 Replies Latest reply on Jan 31, 2007 1:36 AM by tejasjani

    Urgent Help requested ...support for enums..update jbossws g

    sursha

      Hi,
      I want to use enumerations in wsdl. I've a ejb3 exposed web service deployed in jboss 4.0.4 GA.
      I tried defining a java class with static final constants , but it the constants wont show up in wsdl. I also tried using enums in a java class, that also wont show up as enumerations in wsdl. Is there a way for java enums to show up in the generated wsdl?
      Or can i edit the generated the wsdl to support enumerations and deploy to jboss?

      Please advise...

      Thanks
      Suresh

        • 1. Re: Urgent Help requested ...support for enums..update jboss
          t_skowronek
          • 2. Re: Urgent Help requested ...support for enums..update jboss
            jason.greene

            We have java-wsdl support for old jdk 1.4 typesafe enums (see the JAX-RPC spec for examples).

            When we release JAX-WS we will have jdk5 enum support.

            -Jason

            • 3. Re: Urgent Help requested ...support for enums..update jboss
              sursha

              Thank you. I was able to get enums working. I created a test wsdl with enums and generated code using wsdl2java. Used that code as a template in the web service and when jbossws autogenerated wsdl, it created enums !!
              Cool.

              • 4. Re: Urgent Help requested ...support for enums..update jboss
                joshua_hj

                Hi,

                I was trying to develop a parlay X web service, the MultimediaMessaging one. I have managed to generate all java classes from the wsdl and xsd files provided by the specification. Allthough, i am having a problem with enumerations. I have a type, named "MessagePriority" (see below) that is mapped into a java enum file "MessagePriority" (see below) . JBoss complains about the Enumeration type at deploy time. When i remove the references to that type it works fine.

                Does the generated code below is supported by JBossWS?
                Can i use enumeration at all?

                PS: Can you explain better how did you managed to get your enums work

                Best Regards Joshua


                
                EXCEPTION
                
                23:31:27,785 ERROR [MainDeployer] Could not create deployment: file:/C:/Java/jboss-4.0.5.GA/server/all/deploy/MultimediaMessaging.war
                org.jboss.ws.WSException: JAX-RPC Enumeration type did not conform to expectations
                 at org.jboss.ws.tools.schema.SchemaTypeCreator.handleJAXRPCEnumeration(SchemaTypeCreator.java:374)
                 at org.jboss.ws.tools.schema.SchemaTypeCreator.generateNewType(SchemaTypeCreator.java:317)
                 at org.jboss.ws.tools.schema.SchemaTypeCreator.getType(SchemaTypeCreator.java:273)
                 at org.jboss.ws.tools.schema.SchemaTypeCreator.generateType(SchemaTypeCreator.java:132)
                 at org.jboss.ws.tools.schema.SchemaTypeCreator.generateType(SchemaTypeCreator.java:127)
                 at org.jboss.ws.tools.schema.SchemaTypeCreator.createFieldParticle(SchemaTypeCreator.java:607)
                 at org.jboss.ws.tools.schema.SchemaTypeCreator.introspectJavaProperties(SchemaTypeCreator.java:592)
                
                ##############################
                ##############################
                
                SCHEMA
                
                <xsd:simpleType name="MessagePriority">
                 <xsd:restriction base="xsd:string">
                 <xsd:enumeration value="Default"/>
                 <xsd:enumeration value="Low"/>
                 <xsd:enumeration value="Normal"/>
                 <xsd:enumeration value="High"/>
                 </xsd:restriction>
                </xsd:simpleType>
                
                
                ##############################
                ##############################
                
                JAVA
                
                @XmlEnum
                public enum MessagePriority {
                
                 @XmlEnumValue("Default")
                 DEFAULT("Default"),
                 @XmlEnumValue("High")
                 HIGH("High"),
                 @XmlEnumValue("Low")
                 LOW("Low"),
                 @XmlEnumValue("Normal")
                 NORMAL("Normal");
                 private final String value;
                
                 MessagePriority(String v) {
                 value = v;
                 }
                
                 public String value() {
                 return value;
                 }
                
                 public static MessagePriority fromValue(String v) {
                 for (MessagePriority c: MessagePriority.values()) {
                 if (c.value.equals(v)) {
                 return c;
                 }
                 }
                 throw new IllegalArgumentException(v.toString());
                 }
                
                }
                
                


                • 5. Re: Urgent Help requested ...support for enums..update jboss
                  sursha

                  create your enum class in the following format.


                  public class SortingTypes implements java.io.Serializable
                  {
                  private java.lang.String _value_;
                  private static java.util.HashMap _table_ = new java.util.HashMap();

                  // Constructor
                  protected SortingTypes(java.lang.String value)
                  {
                  _value_ = value;
                  _table_.put(_value_,this);
                  }

                  public static final java.lang.String _ASC = "ASC";
                  public static final java.lang.String _DESC = "DESC";
                  public static final SortingTypes ASC = new SortingTypes(_ASC);
                  public static final SortingTypes DESC = new SortingTypes(_DESC);
                  public java.lang.String getValue() { return _value_;}
                  public static SortingTypes fromValue(java.lang.String value)
                  throws java.lang.IllegalArgumentException
                  {
                  SortingTypes enumeration = (SortingTypes)
                  _table_.get(value);
                  if (enumeration==null) throw new java.lang.IllegalArgumentException();
                  return enumeration;
                  }
                  public static SortingTypes fromString(java.lang.String value)
                  throws java.lang.IllegalArgumentException
                  {
                  return fromValue(value);
                  }
                  public boolean equals(java.lang.Object obj) {return (obj == this);}
                  public int hashCode() { return toString().hashCode();}
                  public java.lang.String toString() { return _value_;}
                  public java.lang.Object readResolve() throws java.io.ObjectStreamException { return fromValue(_value_);}

                  }

                  • 6. Re: Urgent Help requested ...support for enums..update jboss
                    tejasjani

                    Hi,

                    can someone give any tips on how to modify the mapping file after writing the enum classes as described in previous post.

                    thanks