On 6 Dec 2005 18:43:58 -0800,
ha************@autodesk.com wrote:
using .net 1.1
i think i might want to replace the xml serializer which my .Net
webservice uses with a custom serializer. anyone know:
a) is this possible?
b) if so, is it terribly difficult (to create a proper webservice
compliant serializer and override the .net "default" webservice xml
serializer)?
As far as I can tell, it's not possible. Seems like the way to control
webservice xml serialization is via the various attributes....
hawkeye parker
A reply I got to from "Mork" just today may be just what you need: look up
"SoapExtension class" in the MSDN library index.
It won't let you replace the default serializer, but you can extend it.
A sample is included in the docs that logs raw requests and replies to an
xml file, but you can change or replace the XML on the fly.
Basically, you create two new classes, one derived from SoapExtension and
one from SoapExtensionAttribute.
The attribute you created this way can be applied to the method that
processes the request. Now when that method is called, a "ProcessMessage"
method in your SoapExtension-derived class is executed with access to the
raw XML (four times actually, at different stages of serialization and
deserialization).
Two catches I stumbled over:
1) you get one stream and create another in the ChainStream method, look
very carefully in the sample which stream is used for what in the request,
and ditto in the reply. It is not always so that the existing stream you
are passed in ChainStreams contains the original data.
2) even if you do not change anything to the XML, you _must_ create a new
stream in ChainStreams and copy data from one stream to the other in
ProcessMessage, as in the sample (which also doesn't change anything).
It didn't work when I just handed it back its own stream.