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 2005

Tip: Looking for answers? Try searching our database.

Override customXML Serialization on Web Service-returned class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Angelos Karantzalis - 22 Feb 2005 15:24 GMT
Hi y'all,

we're using a bunch of classes in a project, that we wanted to convert
to-from xml easily. So, we defined XmlAttribute annotations for our class
members and all worked fine. The Xml stream came from an external source
with a custom xml schema, so we had no alternative.

However, along the way we came to the point that we must expose those
classes as return types for a web service. Returning an instance of a class
through the web service though, we noticed that the resulting xml is not the
normal SOAP-y xml we expected, but rather our class, serialized with the
annotations we'd put in it beforehand.

Can we 'override' that serialization behavior and have the web service
framework do what it would normally do and serialize the class in the
expected way ?

Cheers,
Angel
O:]
Dino Chiesa [Microsoft] - 22 Feb 2005 21:10 GMT
I don't quite understand the problem here.

The XmlAttribute and other attributes you can apply to classes, will affect
the behavior of .NET's XML serialization.  XML Serialization is used when
you are just doing conversions (to and from XML) , which is to say direct
serialization.  But it also is used in .NET for webservices, implicitly.

The resulting XML stream in your SOAP requests or responses, should be SOAP
compliant, with or without your attributes.  It's still SOAP. It might be
shaped differently, but it's SOAP.  You say, it's not the "normal SOAP-y
xml" you expect, but what is not normal about it, precisely?   Does it not
work?  Can it not be de-serialized on the other end of the webservice?  Is
it an aesthetic thing?

If you really want to serialize the same class in 2 different manners ,
there are ways to go.  Two of them I can think of are:
1. define an adapter or bridge class.  It is a companion to the original
class, and can take a different set of XML serialization attributes.
2. specify the XML attributes you want for webservices on the class, and
then specify attribute overrides for when you do direct serialization.

-Dino

> Hi y'all,
>
[quoted text clipped - 18 lines]
> Angel
> O:]
Angelos Karantzalis - 23 Feb 2005 08:15 GMT
Thank you very much Dino. Those were the ways I was thinkin' of as well.

The problem arised from the client, where it is an html page with Microsofts
Web Service behavior running on it, which doesn't like my XML Serialization
format :] At this point, we at a solution where we parse  the XML returned
from the web service & create JScript object graphs semi-automatically, but
we're exploring our server-side options as well.

Cheers,
Angel
O:]

> I don't quite understand the problem here.
>
[quoted text clipped - 41 lines]
> > Angel
> > O:]

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.