473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Override customXML Serialization on Web Service-returned class

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:]
Nov 23 '05 #1
2 2449
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
"Angelos Karantzalis" <ak**********@yahoo.com> wrote in message
news:eR*************@TK2MSFTNGP15.phx.gbl...
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:]

Nov 23 '05 #2
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:]

"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
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
"Angelos Karantzalis" <ak**********@yahoo.com> wrote in message
news:eR*************@TK2MSFTNGP15.phx.gbl...
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:]


Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Picho | last post by:
Hi all. Trying to serialize and desirialize an object. the object is transfered as a byte using a web service to the client. the client then has to deserialize the byte to an object and work...
5
by: Jim Corey | last post by:
I've just learned that the app I've been working on is going to be deployed to a web farm. The app uses session variables, and I've been told that I want to use some other technique. I was...
8
by: vinay | last post by:
Hi Guys I want to understand Serialization. What is serialization. When do we need to use?? What are advantages and Disadvantages. Also please diret me to some good sites on serialization....
0
by: Guogang | last post by:
How can I customize the XML serialization for web service parameters? Speicifically, I am using DateTime as parameter of web service function call. I'd like to be able to control the XML...
1
by: Thomas Qvist | last post by:
We are building a suite of programs consisting of both winforms applications and office addins. We would like to pre-generate the xml-serialization classes and add it to our project to avoid...
0
by: mshetty | last post by:
Hi, Is it possible to override the default de-serialization of parameters sent to a Web Method written using SoapRpcMethod keyword? Thanks and Regards, M Shetty
0
by: Robert Altland | last post by:
I've encountered the following exception when deploying my solution to a load balanced environment: Unable to find assembly 'App_WebReferences.wayyy8_t, Version=0.0.0.0, Culture=neutral,...
7
by: =?Utf-8?B?U3R1?= | last post by:
I have a ASP.NET Ajax app (using client library) calling ASP.NET Ajax-enabled web services. We are making use of the javascript proxies generated by ASP.NET Ajax. The problem we have is that the...
5
by: ds | last post by:
Hi all, this is more a poll to ask for opinions and experiences on serialization of objects. What toolkit do you use? If not using a toolkit do you have your own serialization framework? What...
2
by: compurhythms | last post by:
I have a .NET Windows Service that needs to run without interruption for long periods of time (weeks or months). Everything works great except that every once in a great while I get the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.