A Compression SOAP Extension in .NET framework

Generation GTIN - 13 in .NET framework A Compression SOAP Extension
A Compression SOAP Extension
Print EAN 13 In .NET Framework
Using Barcode generation for .NET framework Control to generate, create European Article Number 13 image in .NET applications.
The preceding SOAP extensions read the request message and take the appropriate actions based on what s in the message and how they are configured I ll now show you a SOAP extension that modifies the message stream on both the client and the service side Listing 10-10 shows the CompressExtension SOAP extension class
GS1 - 13 Recognizer In Visual Studio .NET
Using Barcode reader for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Listing 10-10 The compression SOAP Extension (VBWSBook\10\Infrastructure\Compressvb)
Barcode Generator In .NET
Using Barcode creation for .NET Control to generate, create bar code image in Visual Studio .NET applications.
Imports SystemWebServices Imports SystemWebServicesProtocols Imports SystemConfiguration Imports SystemIO Public Enum CompressionTypes GZip None End Enum Public Class CompressExtension Inherits SystemWebServicesProtocolsSoapExtension
Scanning Bar Code In .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET applications.
Private _CompressionType As CompressionTypes
Creating GS1 - 13 In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create UPC - 13 image in ASP.NET applications.
TEAM FLY PRESENTS
Encoding Barcode In .NET Framework
Using Barcode creator for .NET framework Control to generate, create bar code image in .NET applications.
Private _workStream As CompressDecompressStream
Printing GS1 - 13 In VS .NET
Using Barcode drawer for .NET Control to generate, create European Article Number 13 image in Visual Studio .NET applications.
Public Overloads Overrides Function GetInitializer( _ ByVal serviceType As SystemType) As Object Dim compressionType As String = "" compressionType = _ ConfigurationSettingsAppSettingsGet("CompressionType") If Not (compressionType Is Nothing) Then Select Case compressionTypeToLower Case "gzip" Return CompressionTypesGZip Case Else Return CompressionTypesNone End Select Else 'GZip is default Return CompressionTypesGZip End If End Function
ANSI/AIM Code 39 Encoder In .NET Framework
Using Barcode encoder for Visual Studio .NET Control to generate, create Code 39 Full ASCII image in .NET framework applications.
Public Overloads Overrides Function GetInitializer( _ ByVal methodInfo As LogicalMethodInfo, _ ByVal attribute As SoapExtensionAttribute) As Object
Creating Data Matrix ECC200 In VS .NET
Using Barcode maker for VS .NET Control to generate, create Data Matrix image in .NET framework applications.
Return CType(attribute, CompressAttribute)CompressionType
Painting Identcode In .NET Framework
Using Barcode creator for .NET framework Control to generate, create Identcode image in .NET applications.
End Function
Reading Bar Code In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
TEAM FLY PRESENTS
Encoding Code39 In C#.NET
Using Barcode encoder for .NET Control to generate, create Code 3/9 image in .NET framework applications.
Public Overrides Sub Initialize(ByVal initializer As Object) _CompressionType = CType(initializer, CompressionTypes) End Sub Public Overrides Function ChainStream( _ ByVal stream As SystemIOStream) As SystemIOStream _workStream = New CompressDecompressStream(stream) _workStreamCompressionType = _CompressionType Return _workStream End Function
Encode Code-39 In VB.NET
Using Barcode generator for VS .NET Control to generate, create ANSI/AIM Code 39 image in Visual Studio .NET applications.
Public Overrides Sub ProcessMessage(ByVal message As _ SystemWebServicesProtocolsSoapMessage) If messageStage = SoapMessageStageAfterSerialize Then _workStreamClose() End If End Sub End Class
Barcode Generator In .NET Framework
Using Barcode drawer for ASP.NET Control to generate, create barcode image in ASP.NET applications.
I wanted users to be able to apply this SOAP extension to an entire vroot via webconfig as well as to specific Web methods via a custom attribute Therefore, I needed to implement initialization code in both overloads of GetInitializer The first GetInitializer in listing 10-10 is called if the extension is applied via Webconfig In this case, I read the configuration setting called CompressionType from webconfig There are two possible values for ths setting: GZip and None This allows users to turn compression on/off without actually removing the SOAP extension It also allows future extensibility by implementing new compression algorithms and adding them to the set of possible values of the CompressionType setting If CompressionType is not found in webconfig, the default is GZip Similarly, the second implementation of GetInitializer in listing 10-10 converts the attribute parameter to an instance of CompressAttribute (see listing 10-11) then returns the CompressionType property of the attribute This allows developers to apply the extension by applying the CompressAttribute attribute to Web methods Regardless how the SOAP extension was applied, when Initialize is called it receives the configured compression type in its initializer parameter Initialize simply converts initializer to the CompressionTypes and stores it in the _CompressionType private field Since this SOAP extension modifies message streams, it overrides ChainStream When ChainStream is called, I create a new instance of CompressDecompressStream which is a custom stream class that does the compression/decompression I ll explain this class shortly Before returning this instance of CompressDecompressStream, I set its CompressionType property to the specified compression type Finally, in ProcessMessage, I ignore all message stages except for AfterSerialize When ProcessMessage is called in AfterSerialize the response message has already been compressed by our stream To flush out the stream and close it, I call _workStreamClose() Without this important
Generating Data Matrix In C#.NET
Using Barcode generator for .NET framework Control to generate, create DataMatrix image in VS .NET applications.
TEAM FLY PRESENTS
Decode Bar Code In .NET Framework
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET framework applications.
step you d see weird behavior where sometimes the extension works fine and other times you get only a fraction of the response message back to the client
Barcode Encoder In Java
Using Barcode creator for Java Control to generate, create barcode image in Java applications.
Listing 10-11 CompressAttribute is used to apply the compression extension to specific methods (VBWSBook\10\Infrastructure\Compressvb)
Recognize Universal Product Code Version A In .NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications.
<AttributeUsage(AttributeTargetsMethod)> _ Public Class CompressAttribute Inherits SoapExtensionAttribute
Paint EAN / UCC - 14 In Java
Using Barcode maker for Java Control to generate, create GS1-128 image in Java applications.
Private _Priority As Integer = 0 Private _CompressionType As CompressionTypes
Bar Code Generator In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create bar code image in ASP.NET applications.
Public Sub New() MyBaseNew() 'GZip is default _CompressionType = CompressionTypesGZip End Sub Public Sub New(ByVal compressType As CompressionTypes) MyBaseNew() _CompressionType = compressType End Sub Public Overrides ReadOnly Property ExtensionType() As SystemType Get Return GetType(CompressExtension) End Get End Property Public Overrides Property Priority() As Integer Get
TEAM FLY PRESENTS
Return _Priority End Get Set(ByVal Value As Integer) _Priority = Value End Set End Property Public Property CompressionType() As CompressionTypes Get Return _CompressionType End Get Set(ByVal Value As CompressionTypes) _CompressionType = Value End Set End Property End Class
Listing 10-12 shows the CompressDecompressStream which inherits from SystemIOStream and performs compression when writing and decompression when reading Listing 10-12 CompressDecompressStream does the real compression/decompression work (VBWSBook\10\Infrastructure\CompressDecompressStreamvb)