A
AndyMalakov
Hello All,
I noticed that System.Web.Services.Protocols.XmlReturnReader in .NET
Framework 2.0 (v2.0.50727) no longer capable of de-serializing custom
data types. This is vital capability for non-SOAP based web services
(REST, etc).
It appears that now set of supported types is limited to types
supported by System.Web.Services.Protocols.ScalarFormatter (such as:
int, long, double, string, and few other predefined types).
This new feature results in internal exception on attempt to use web
service with method returning custom type:
[HttpMethodAttribute(typeof(XmlReturnReader), ...)]
public MyCustomResult foo (...) { ... }
Here is the exception stack trace:
System.IndexOutOfRangeException: Index was outside the bounds of the
array.
at System.Web.Services.Protocols.HttpClientType..ctor(Type type)
at System.Web.Services.Protocols.HttpSimpleClientProtocol..ctor()
at System.Web.Services.Protocols.HttpPostClientProtocol..ctor()
at MyNS.MyServiceClient..ctor()
The same code worked fine with version 1.1.
There is a workarond - Extend XmlReturnReader and override
GetInitializers() method to return XmlSerializer according to resulting
type.
P.S. God bless Lutz Roeder and his .NET Reflector
All the Best,
Andy
I noticed that System.Web.Services.Protocols.XmlReturnReader in .NET
Framework 2.0 (v2.0.50727) no longer capable of de-serializing custom
data types. This is vital capability for non-SOAP based web services
(REST, etc).
It appears that now set of supported types is limited to types
supported by System.Web.Services.Protocols.ScalarFormatter (such as:
int, long, double, string, and few other predefined types).
This new feature results in internal exception on attempt to use web
service with method returning custom type:
[HttpMethodAttribute(typeof(XmlReturnReader), ...)]
public MyCustomResult foo (...) { ... }
Here is the exception stack trace:
System.IndexOutOfRangeException: Index was outside the bounds of the
array.
at System.Web.Services.Protocols.HttpClientType..ctor(Type type)
at System.Web.Services.Protocols.HttpSimpleClientProtocol..ctor()
at System.Web.Services.Protocols.HttpPostClientProtocol..ctor()
at MyNS.MyServiceClient..ctor()
The same code worked fine with version 1.1.
There is a workarond - Extend XmlReturnReader and override
GetInitializers() method to return XmlSerializer according to resulting
type.
P.S. God bless Lutz Roeder and his .NET Reflector
All the Best,
Andy