SOAP Extensions
What replacement in WCF should I be using for an ASP.NET SoapExtension?
A SOAP extension is an extensibility point in ASMX that allows processing of SOAP messages during sending and receiving. WCF has many extensibility points for processing messages so the question is really about which extensibility point is the closest match to the functionality provided by the SoapExtension class. SoapExtension has a single ProcessMessage method that is called for four different message states (the descriptions are from the server's perspective):
1.
BeforeDeserialize, the request before going through the XML serializer
2.
AfterDeserialize, the request after going through the XML serializer
3.
BeforeSerialize, the response before going through the XML serializer
4.
AfterSerialize, the response after going through the XML serializer
All of these calls could be replaced by an IDispatchMessageFormatter, which allows control over the serialization process. You could add hooks to the DeserializeRequest and SerializeReply methods of an IDispatchMessageFormatter to process the messages immediately before or after the serializer invocation. However, this requires knowledge about the serialization process. It lacks the convenience of having a pipeline of processors that don't require knowledge of the steps of the serialization pipeline. Although the functionality is centralized as it is in SoapExtension, this is the wrong extensibility point to use.
Message inspectors are a more convenient mechanism for processing messages while they are in an XML form. The AfterReceiveRequest and BeforeSendReply methods of an IDispatchMessageInspector correspond to the BeforeDeserialize and AfterSerialize states.
Parameter inspectors are a more convenient mechanism for processing service method invocations while they are in a parameterized form. The AfterCall and BeforeCall methods of an IParameterInspector correspond to the AfterDeserialize and BeforeSerialize states.
WCF has an equivalent client interface for a message inspector and uses the same interface for a parameter inspector.
Next time: Stripping Out Extra Endpoints
Comments
- Anonymous
October 03, 2007
Inside a service, there's a fundamental loop running whose job it is to create channels for the incoming