18.8 Using Channels and Formatters

 <  Day Day Up  >  

You want to specify what channels and formatters are used.


Technique

The .NET Framework 1.1 offers two channels with two formatters. The channel is responsible for transferring the method call in a form of a message from the client to the server and from the server to the client. The formatter is responsible for converting the method call and parameters to pass it across the network.

The HTTP channel by default uses the SOAP formatter, but the TCP channel by default uses the binary formatter. The binary formatter is more efficient compared to the SOAP formatter.

The server example uses both available channels, so the server is available both by TCP and HTTP channels. After that, the formatter of the HTTP channel is changed to a binary formatter.

You can add the channel to be used to the <channels> recipe in the remoting configuration file:

 
 <channels>     <channel port="8088" ref="http" />     <channel port="8989" ref="tcp" /> </channels> 

To change the default formatter of a channel, you can set the <serverProviders> element with the child element <formatter> to specify a different formatter ”in this example, a binary formatter with the HTTP channel:

 
 <channels>     <channel port="8088" ref="http">         <serverProviders>             <formatter ref="binary" />         </serverProviders>     </channel>     <channel port="8989" ref="tcp" /> </channels> 

Comments

In the configuration file, you can define what channel to use. The configuration of the channel can be very simple, using a reference (with the ref attribute) to a channel that is already configured in the file machine.config .

With SOAP, you have to be aware that multiple SOAP styles do exist. The default SOAP style used by ASP.NET Web Services is the document style, which is the newer style. The .NET Remoting SOAP formatter just supports the older RPC style.

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net