XmlReturnReader in 2.0 does not support custom types?

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
 

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,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top