ASP.NET.in.a.Nutshell.Second.Edition [Electronic resources]

G. andrew Duthie; matthew Macdonald

نسخه متنی -صفحه : 873/ 360
نمايش فراداده

SoapExtension

System.Web.Services.Protocols (system.web.services.dll)abstract class

You can inherit from this class to create a custom SOAP extension, which allows you to access and manipulate SOAP messages before they are sent or converted into objects. SOAP extensions can be used to implement additional encryption, compression, or tracing. They can also be applied to web services or web service clients.

The key to using a derived SoapExtension class is overriding the ProcessMessage( ) method. This method is called automatically by the ASP.NET framework at several different SoapMessageStages and provides you with the current SoapMessage object. You also connect your SoapExtension to a proxy class or web service method by using a custom SoapExtensionAttribute.

You can initialize a SoapExtension with a constructor method and the Initialize( ) and GetInitializer( ) methods. The GetInitializer( ) method is called only once (the first time a SOAP request is made). It gives you the opportunity to retrieve information about the web service or proxy method (in the methodInfo parameter) and custom SoapExtensionAttribute and return an appropriate initialization object. This object will be cached and provided to the Initialize( ) method, which is called every time a SOAP request is made.

public abstract class 

SoapExtension { // Protected Constructors protected

SoapExtension ( ); // Public Instance Methods public virtual Stream

ChainStream (System.IO.Stream

stream ); public abstract object

GetInitializer (LogicalMethodInfo

methodInfo , SoapExtensionAttribute

attribute ); public abstract object

GetInitializer (Type

serviceType ); public abstract void

Initialize (object

initializer ); public abstract void

ProcessMessage (SoapMessage

message ); }