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