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 Leon Hwang <hw...@mystrands.com> on 2007/08/30 04:06:40 UTC

[Axis2] Enum

Can someone explain how I can return enum type object from Axis2 server?

I am using Axis2 1.3 / Tomcat 6.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [Axis2] Enum

Posted by Sanka Samaranayake <ss...@gmail.com>.
AFAIK new Axis2 doesn't support this feature.

Best,
Sanka

On 8/30/07, Leon Hwang <hw...@mystrands.com> wrote:
>
> Can someone explain how I can return enum type object from Axis2 server?
>
> I am using Axis2 1.3 / Tomcat 6.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Sanka Samaranayake
WSO2 Inc.

http://www.bloglines.com/blog/sanka
http://www.wso2.org/

Re: [Axis2] Enum

Posted by Leon Hwang <hw...@mystrands.com>.
Amil,

First, please refer to the attached email.
According to Sanka, the enum type fix is on the table for the next release.
I would like to confirm with you this would be in Axis2 1.4.
By the way, when does it get released? In October?

To respond to your answer:
Yes, wsdl2java might support enum type.
But the problem is that the server spits out a complex type instead of a simple type with restrictions.
Please try it yourself.
This problem could be solved by writing a custome WSDL or a custome data locator.

However, here's the REAL main problem.
The server does NOT work with any enum type.
You will encounter a runtime exception when it returns or accepts an enum type.

I wonder if this is all solved in the nightly-build version now.

Thanks,

- Leon



Amila Suriarachchi wrote:
> 
> 
> On 9/3/07, *Mark Nüßler* <mark.nuessler@9elements.com 
> <ma...@9elements.com>> wrote:
> 
>     hello leon,
> 
>     it seems to me, that java2wsdl and wsdl2java does not support enums.
> 
> 
> wsdl2java support this.  in a wsdl enumeration is represented by a 
> simple type restriction enumeration.
> eg.
> <simpletype name="test">
>   <restriction base = "xs:string">
>      <enumeration value="testvalue"/>
>   </restriction>
> </simpletype>
> 
> and this type of xsd are supported in wsdl2java.
> 
>     a workaround that works 4 me is to replace the enum with a String
>     before generating anything.
> 
>     on the serverside convert your enum to String
> 
>     Gender g = Gender.MALE;
>     String g_send = g.toString();
> 
>     an on clientside test, if the String is a valid enum
> 
>     try {
>             Gender g_test = Gender.valueOf (g_send.toUpperCase());
>             System.out.println("valid Gender");
>     } catch(Exception e) {
>             System.out.println("invalid Gender");
>     }
> 
>     i know its just a workaround
> 
>     mfg derMark
> 
> 
> 
> 
> 
> 
> 
>     Leon Hwang schrieb:
>      > Can someone explain how I can return enum type object from Axis2
>     server?
>      >
>      > I am using Axis2 1.3 / Tomcat 6.
>      >
>      >
>     ---------------------------------------------------------------------
>      > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>
>      > For additional commands, e-mail: axis-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>      >
>      >
>      >
> 
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-user-help@ws.apache.org
>     <ma...@ws.apache.org>
> 
> 
> 
> 
> -- 
> Amila Suriarachchi,
> WSO2 Inc.

-- 
Leon Hwang
MyStrands, Inc.

work: 1.541.753.4426
mobile: 1.541.740.7511
fax: 1.541.754.6416
email: hwang@MyStrands.com

Re: [Axis2] Enum

Posted by Amila Suriarachchi <am...@gmail.com>.
On 9/3/07, Mark Nüßler <ma...@9elements.com> wrote:
>
> hello leon,
>
> it seems to me, that java2wsdl and wsdl2java does not support enums.


wsdl2java support this.  in a wsdl enumeration is represented by a simple
type restriction enumeration.
eg.
<simpletype name="test">
  <restriction base = "xs:string">
     <enumeration value="testvalue"/>
  </restriction>
</simpletype>

and this type of xsd are supported in wsdl2java.

a workaround that works 4 me is to replace the enum with a String
> before generating anything.
>
> on the serverside convert your enum to String
>
> Gender g = Gender.MALE;
> String g_send = g.toString();
>
> an on clientside test, if the String is a valid enum
>
> try {
>         Gender g_test = Gender.valueOf(g_send.toUpperCase());
>         System.out.println("valid Gender");
> } catch(Exception e) {
>         System.out.println("invalid Gender");
> }
>
> i know its just a workaround
>
> mfg derMark
>
>
>
>
>
>
>
> Leon Hwang schrieb:
> > Can someone explain how I can return enum type object from Axis2 server?
> >
> > I am using Axis2 1.3 / Tomcat 6.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Amila Suriarachchi,
WSO2 Inc.

Re: [Axis2] Enum

Posted by Mark Nüßler <ma...@9elements.com>.
hello leon,

it seems to me, that java2wsdl and wsdl2java does not support enums.

a workaround that works 4 me is to replace the enum with a String
before generating anything.

on the serverside convert your enum to String

Gender g = Gender.MALE;
String g_send = g.toString();

an on clientside test, if the String is a valid enum

try {
	Gender g_test = Gender.valueOf(g_send.toUpperCase());
	System.out.println("valid Gender");
} catch(Exception e) {
	System.out.println("invalid Gender");
}

i know its just a workaround

mfg derMark







Leon Hwang schrieb:
> Can someone explain how I can return enum type object from Axis2 server?
> 
> I am using Axis2 1.3 / Tomcat 6.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org