Now that you are familiar with the major classes and interfaces that the
WCF LOB Adapters have to support, let's put all the pieces together and
implement a simple adapter for a mythical hotel reservation system. In
the inbound scenario, an adapter monitors the system and sends
notification if new guests arrive. In the outbound scenario, an adapter
accepts requests and returns the number of available rooms for the
specified hotel.
1. Step 1: Generating Adapter Skeleton Code
First, you have to create WCF LOB Adapter project.
Begin by using Visual Studio's WCF LOB Adapter Development Wizard to
generate some skeleton code. Here is the process to follow:
To create a WCF LOB Adapter project, open Visual Studio 2008. Select File =>
New Project. The New Project dialog box will open. Select a Visual C#
project for the project type, and select WCF LOB Adapter from the
Templates pane. Specify the project name and location, as shown in Figure 1.
Click OK. The WCF LOB Adapter Development Wizard, shown in Figure 2, will open.
Click Next.
On the Scheme, Namespace and URI Information page, specify the parameters shown in Figure 3.
If you want to override the default namespace, select the "Override
default namespace" check box, and type the desired namespace in the
"Service namespace" field.
Specify the parameters shown in Figure 4, and click the Next button.
On the Adapter Properties page, add the binding properties listed in Table 1.
The EnableConnectionPooling property is used by the ASDK to enable or
disable the runtime connection pooling. Make sure that after adding the
properties, the Adapter Properties page looks like Figure 5. Click the Next button.
Table 1. Adapter Binding Properties
Property Name | Data Type | Default Value |
---|
EnableConnectionPooling | System.Boolean | True |
PollingPeriod | System.Integer | 10 |
On the Connection Properties page, add the connection properties listed in Table 2. After adding the properties, the Connection Properties page should look like Figure 6.
Table 2. Adapter Connection Properties
Property Name | Data Type | Default Value |
---|
Application | System.String | HotelApp |
EnableAuthentication | System.Boolean | True |
Host | System.String | HotelAppHost |
Click the Next button. On the Summary page, click the Finish button. Figure 7 shows the Solution Explorer with the files generated by the WCF LOB Adapter Development Wizard.
Tables 3 to 7 give a brief description of the files generated by the wizard.
Table 3. Connection Group
File | Description |
---|
HotelAdapterConnection.cs | Contains the definition of the class implementing the IConnection interface. This class is responsible for a single connection to the target LOB system. |
HotelAdapterConnectionFactory.cs | Contains the definition of the class implementing the IConnectionFactory interface. This class creates an instance of the class implementing the IConnection interface, that is, HotelAdapterConnection. |
HotelAdapterConnectionUri.cs | Contains the definition of the class representing connection string to the target LOB system. |
Table 4. Metadata Handlers Group
File | Description |
---|
HotelAdapterMetadataBrowseHandler.cs | Contains the definition of the class implementing the IMetadataBrowseHandler interface. This class is responsible for the metadata browse capabilities of the adapter. |
HotelAdapterMetadataResolverHandler.cs | Contains the definition of the class implementing the IMetadataResolverHandler
interface. This interface is used by ASDK to get the information about
supported operations and data types. This information is used to
generate proxy files or message type specifications. |
HotelAdapterMetadataSearchHandler.cs | Contains the definition of the class implementing the IMetadataSearchHandler interface. This class is responsible for the search metadata capabilities of the adapter. |
Table 5. Inbound/Outbound Handlers Group
File | Description |
---|
HotelAdapterHandlerBase.cs | Contains the definition of the base class for adapter handlers. |
HotelAdapterInboundHandler.cs | Contains the definition of the class implementing the IOutboundHandler interface. This class is responsible for listening to events or polling for data on the target LOB system. |
HotelAdapterOutboundHandler.cs | Contains the definition of the class implementing the IInboundHandler interface. This class is responsible for sending data to the target system. |
Table 6. Custom Binding Group
File | Description |
---|
HotelAdapterBinding.cs | Contains the definition of the class representing a binding for the WCF LOB Adapter. This class hosts a collection of the BindingElements, which the WCF channel is built upon. |
HotelAdapterBindingCollection Element.cs | Contains the definition of the class used to register the adapter with WCF. |
HotelAdapterBindingElement.cs | This class is used to apply configuration properties to the adapter binding. |
HotelAdapterBindingElementExtensionElement.cs | Contains
the definition of the class used to expose the adapter as a custom
adapter binding. This class is used to configure the adapter using the
WCF-custom adapter. |
Table 7. Core Files
File | Description |
---|
HotelAdapter.cs | Contains the definition of the main adapter class derived from Microsoft.ServiceModel.Channels.Common.Adapter. |
HotelAdapterTrace.cs | Contains the definition of a supplementary class that can be used in the code for debugging purposes and tracing in particular. |
After completing this step,
you have WCF LOB Adapter skeleton classes that you will fill with
functionality in the subsequent steps. In the next step, you will
categorize the properties that you created using the wizard.