Last Lap Around ASMX and Stuffs before moving to WCF:-Part II

Posted: November 29, 2006 in Uncategorized
This post is a continuation of Post 1 of the series of posts i am writing on the Asmx Stuff to WCF route.Do read the First Part Here.
To refresh u  in this series of posts i am trying to cover the issues,,hype,standards,practices and happening in Webservices to WCF Journey and i ll try to provide references and links  as well as few writeup and my views on the same.I ll also try to cover WSE,WS* and few other simlilar topics on the same road.
 
 
In Part1 I have started with providing the new features in asmx 2.0 except the IxmlSerlizable and SchemaimporterExtensions which I ll cover Now before delving into the depth further:-
 
IxmlSerlizable and SchemaImporterExtension:-
 
This interface although presents in framework 1.1 was not documented and this usage was notimpemented by many.What this menat for you??Well ever you tried to take control over the webservice serlization mechanism or did u ever tried to take control over the schema generation  of webservices?
 
if your answer is yes then you might be aware of the fact that the default xmlserlization of webservice might not be always what you are expecting out of the serlization wire.Let say you want to serilized a type which didn’t implement the Iserilizable ,let say you want to serilize a hashtable,another example might be you want send data in chunks instead of a large set ..then friend the IxmlSerlizable interface is your friend which not only let you control over the Serilization and Deserilization  but also it helps you in controlling the schema generation[which you might control to certain extent by denoting various xml and typeof attributes on top of webmethods].
 
 
To control the serilization , implement the ReadXml and WriteXml methods to control the XmlReader and XmlWriter classes used to read and write the XML.To control the schemageneration you must apply the XmlSchemaProviderAttribute to the serializable type, and specify the name of the static member that returns the schema.Further to that the class that  implements the interface must  have a parameterless default constructor.
 
A quick and useful example would be you take control of the serilization by implementing the writexml in serverside to chunk your largedata and in client side you implement the readxml or schemaimporter extension to reuinte the data.you can also follow the reverse approach but often this ends with your choice between push or pull model .
 
When i was not aware of the IxmlSerilizable let me admit that i opted the approach of sending data in chunk [in string of course which was a bad choice then then the chunk of strongly typed object   ] to websvc asynchrounously in a  different thread and then to Backend and in Backend i have used the binary Text Column append using pointer and used a similar approach to get the data back.That was a adeqaute solution from the fact that i took over the control of the serilization but no longer you need to follow the same tedious approach
 better you can hookup the writexml and readxml and own the serilization.Let  me mention the important point that you can opt to go for the chunking bacause of the 4096 KB limitation of iis buffering payload[although u can configure the maxrequestlength
in web.config that itself has issues like security and what exactsize you can opt for.
 
Finally one more point to note is that you need not have to implement the getxml method of ixmlserilizable just return Null from it.It can be used only when the DataSet instance is cast to an IXmlSerializable interface.
 
SchemaImporterExtension on the other hand as i mentioned above helps you in controlling the behavior in the otherside by adhering to your code instaed of the code generated by wsdl.exe or the add webref option of the Visualstudio.I had seen quite a few system where the ultimate option was to fall for manually modify the generated proxy in visual studio.One example might be when u return a custom array of objects in Fx 1.1 and you want to bind the result to the grid…you need to manually modify the proxy ..but with the schemaimporter extension you don’t need to manually modify the proxy.
 
Enough of writing  on  this now let me put some example links on this[not providing my own example here since there are already quite a few elegant and good example available on web to refer to :-
Ode to the System.Xml.Serialization.Advanced.SchemaImporterExtension Class
http://www.bristowe.com/blog/PermaLink.aspx?guid=8d22250e-5f9b-444f-b7d6-f11ced23ee49
 
Watch /download the msdn nugget for Ixmlserializable Here.
 
SGEN.EXE :- this tool is meant for serlization performance and startup and often useful for scneario when u are calling the assmebly once.when u r using the sgen generated assembly ur assembly is precompiled and pregenerated and thus is providing performance improvement .further this tool is a useful one sql05 websvc scenario.
 
 
While i was reinventing the wheel on asmx 2.0 i found that there is already a good webcast by kirk and christian had also a series of post on the same.however i have coined them in my way and my intention of this post is not meant to provide the new bits of asmx 2.0 only.Found this post useful ? comment…
 
I ll continue the next post on this series where i ll cover more different issue like compression,REST as well as what is in WSE ,asmx stack and how u ll be faring with WCF with these.its 4 am now and i ll update the post tomorrow to get it back to track of where it started and not on asmx 2.0.good night…oh…good morning…guys…bye..
 
For  Last Part Click Here
 
 
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s