Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2006

Tip: Looking for answers? Try searching our database.

Serialization of derived classes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Angel - 02 Feb 2006 03:53 GMT
I have a Web service that has a method returning a class, so complex
type.
This class is serializable. It works just fine.

I created a secoind method that returns a class derived from the first
one.
The SOAP response lists only the extra fields I added. The fields from
the
base class are not shown. I would like to have all fields included in
the
SOAP response. What should I do ?
Josh Twist - 02 Feb 2006 08:22 GMT
WSDLs have inheritence too (from XSD) so normally, inherited classes
should work just fine, but only the extra fields in the complex type
are displayed.

if you have two classes ClassA and ClassB where ClassB inherits ClassA
- you'd expect to see something like this in the WSDL:

<s:complexType name="ClassB">
  <s:extension base="s0:ClassA">
     <s:sequence>
        <!-- the additional properties added by ClassB go here -->
     </s:sequence>
  </s:extension>
</s:complexType>

The s:extension node is essentially inheritence - says this class (B)
extends class A.

Does that help? Have you tried your service? Are you sure that
something is wrong?
Richard Purchas - 16 Feb 2006 12:42 GMT
XML serialization has problems such as this (and other issues, such as not
serializing private fields etc.). One option is to binary serialize the
custom class and pass as array of byte. This has worked well for me, and
also suppresses generation of proxies for the complex types as well.

>I have a Web service that has a method returning a class, so complex
> type.
[quoted text clipped - 7 lines]
> the
> SOAP response. What should I do ?
Josh Twist - 16 Feb 2006 13:20 GMT
Hi Richard,

Your suggestion kind of defeats the points of Web Services - self
description, interoperability. A client using such a service (with
binary serialization) isn't going to understand anything about your
service from the WSDL and has to be written in .NET.

You might as well use Enterprise services or (dare I say it) Remoting
and avoid the overhead of asmx.

Josh
http://www.thejoyofcode.com/
Richard Purchas - 27 Feb 2006 13:18 GMT
I see your point and agree whole-heartedly, but understand where my comments
came from:

Firstly, the web services I am talking about are used only for internal
purposes. I have a project with dozens of business classes that are passed
to these internal web services. If a Developer uses the out-of-box tools to
create a reference to our web services then they end-up with dozens of
proxies created in my consuming projects, which is a really undesirable
situation to be in.

Additionally, stand XML serialisation simply didn't cut the mustard; private
fields aren't serialised etc.

What alternatives can you offer to get around these two issues (whilst still
permitting use of the tools I refer to) ?

> Hi Richard,
>
[quoted text clipped - 8 lines]
> Josh
> http://www.thejoyofcode.com/

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.