Now that you are becoming familiar with the adapter
fundamentals and you've learned where the WCF LOB Adapter fits into WCF
model, it is time to take a look inside the WCF LOB Adapter in detail. Figure 1 shows the major components and how they interact with each other.
As you can see, the WCF LOB
Adapter as a code entity can be split into two big parts; one part is
provided by the ASDK, and the other part has to be implemented by the
adapter developer. Essentially, a developer—that's you—has to provide
the implementation for three blocks of functionality: the connection,
metadata handlers, and inbound/outbound handlers. The WCF LOB Adapter
Development Wizard generates skeleton classes supporting the required
methods and interfaces; you as the adapter developer need to provide an
implementation specific to the target LOB system.
1. The Connection
Creating and opening a
connection to a LOB system is in many cases an expensive procedure in
terms of machine resources. One of the key features provided by the WCF
LOB Adapter SDK is connection management, which takes the form of connection pooling.
When a connection is
required to perform a metadata or inbound/outbound operation, the WCF
LOB runtime component either creates a new connection or gets an
existing one from a connection pool. When the operation completes, the
WCF LOB SDK runtime component returns a connection to the connection
pool.
To enable connection management, you have to provide the implementation of three interfaces and classes defined in the Microsoft.ServiceModel.Channels.Common namespace. We've listed them for you in Table 13-1.
Table 1. Interfaces and Classes to Implement Connection Management
Class/Interface | Description |
---|
IConnectionFactory | This interface is used by the WCF LOB SDK when it needs to create a new connection to the target LOB system. |
IConnection | This interface encapsulates the methods required to connect to the target LOB system. |
ConnectionUri | The WCF LOB SDK Wizard generates a class extending the abstract ConnectionUri class. You have to provide the implementation of the properties representing a connection string to the target LOB system. |
2. The Metadata Handlers
As we have discussed,
metadata support is an important feature that distinguishes WCF LOB
Adapters from WCF services. To enable an adapter's metadata capability,
you as the adapter developer must implement two mandatory interfaces;
there is also one optional interface (see Table 2). These interfaces are defined in the Microsoft.ServiceModel.Channels.Common namespace.
Table 2. Metadata Interfaces
Interface | Description |
---|
IMetadataBrowseHandler | This
interface represents the browse capability of the WCF LOB Adapters. You
must implement this interface regardless of your adapter functionality. |
IMetadataSearchHandler | Optional. This interface represents the search capability of the WCF LOB Adapters. |
IMetadataResolverHandler | This
interface is used when the WCF LOB Adapter SDK needs to generate the
proxy files in case of .NET applications or XSD specifications in case
of BizTalk applications. You must implement this interface regardless of
your adapter functionality. |
3. The Message Exchange Handlers
Message exchange handlers are represented by four interfaces from the Microsoft.ServiceModel.Channels.Common namespace. We've listed them for you in Table 3.
Table 3. Message Exchange Handlers
Interface | Description |
---|
IOutboundHandler | Supports one-way send or request-response pattern. |
IAsyncOutboundHandler | Optional. Supports asynchronous one-way send or request-response pattern. |
IInboundHandler | Optional. Supports one-way receive or reply pattern. |
IAsyncInboundHandler | Optional. Supports asynchronous one way receive or reply pattern. |