Default enumeration value using Axis SOAP toolkit

B

Bill Poitras

Server:
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:
{http://schemas.xmlsoap.org/soap/envelope/}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
s)
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
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
populated.
 
R

Roedy Green

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.
 
C

Carl Howells

Roedy said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top