Default enumeration value using Axis SOAP toolkit

Discussion in 'Java' started by Bill Poitras, May 12, 2004.

  1. Bill Poitras

    Bill Poitras Guest

    Webservice on Windows 2000 Server, .Net 1.1.
    Serves up an objects similar to the following:

    public enum MyEnum {
    Red = 'R',
    Blue = 'B',
    Green = 'G'

    Public MyValueObject {
    public MyEnum color;
    public int intValue;
    public String stringValue;

    On the client side I create a MyValueObject and initialize the
    stringValue. Everything is left at the default value. I then use
    this object as an argument to a web service call.

    On a .Net client the webservice call occurs, I check to make sure the
    enumeration is a reasonable value, in this case Red because in .Net
    the proxy object is an enumeration with a default value of 0, which
    maps to Red on the client side. The Red = 0 on the client side maps
    to Red = 'R' on the server side.

    In Java because it doesn't support enumerations it creates a class to
    mimic the behavior. However the enumeration value is stored as a
    string in the proxy class which defaults to null. When I make the web
    service call I get the following:

    AxisFault faultCode:
    {}Client faultSubcode:
    faultString: System.Web.Services.Protocols.SoapException: Server was
    unable to read request. ---> System.InvalidOperationException:
    There is an error in XML document (12, 33). --->
    System.InvalidOperationException: '' is not a valid value
    for MyEnum.
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_MyEnum(String
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read1_MyValueObject(Boolean
    isNullable, Boolean checkType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read19_doIt()
    --- End of inner exception stack trace ---
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
    xmlReader, String encodingStyle)
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
    --- End of inner exception stack trace ---
    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
    at System.Web.Services.Protocols.WebServiceHandler.Invoke()
    at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

    My basic question is this:

    Is there a way to specify enumerated values in the WSDL so that I can
    create my value object without having to require callers to initialize
    certain members? I know it isn't a big deal, but I'm looking for a
    simple process for my SOAP API on both .Net and Java
    - Create proxy object code.
    - In client program create a value object. Only populate what you
    need to
    - Call the server with reasonable default for properties not
    Bill Poitras, May 12, 2004
    1. Advertisements

  2. Roedy Green

    Roedy Green Guest

    On 12 May 2004 07:47:28 -0700, (Bill
    Poitras) wrote or quoted :

    >public enum MyEnum {
    > Red = 'R',
    > Blue = 'B',
    > Green = 'G'

    Is there yet a convention on how enum constants should be capitalised?

    Since their names show up in the UI, I presume not.

    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See for The Java Glossary.
    Roedy Green, May 12, 2004
    1. Advertisements

  3. Carl Howells

    Carl Howells Guest

    Roedy Green wrote:
    > On 12 May 2004 07:47:28 -0700, (Bill
    > Poitras) wrote or quoted :
    >>public enum MyEnum {
    >> Red = 'R',
    >> Blue = 'B',
    >> Green = 'G'

    > Is there yet a convention on how enum constants should be capitalised?
    > Since their names show up in the UI, I presume not.

    Note that the code you quoted was the C# (I assume, anyway, since he
    talks about .NET) code, not java 1.5 code.
    Carl Howells, May 12, 2004
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sham Ramakrishnan
    Sham Ramakrishnan
    Jul 1, 2003
  2. Replies:
  3. hocho888
  4. puvit82
    Feb 1, 2008
  5. Prabhu

    .net SOAP toolkit performance for SOAP deserialization

    Prabhu, Nov 12, 2004, in forum: ASP .Net Web Services
    Dan Rogers
    Nov 18, 2004

Share This Page