Search
Windows Server

BizTalk 2009 : WCF LOB Adapter SDK (part 1) - Generating Adapter Skeleton Code

Published 4 min readBy Programming4us Editorial Team
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:
  1. 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.

  2. Click OK. The WCF LOB Adapter Development Wizard, shown in Figure 2, will open.

  3. Click Next.

    Figure 1. Creating a WCF LOB Adapter project

    Figure 2. The WCF LOB Adapter Wizard

  4. 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.

    Figure 3. Scheme, Namespace, and URI Information page

  5. Click the Next button.

  6. Specify the parameters shown in Figure 4, and click the Next button.

    Figure 4. Data flows and metadata features

  7. 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 NameData TypeDefault Value
    EnableConnectionPoolingSystem.BooleanTrue
    PollingPeriodSystem.Integer10

    Figure 5. Adapter Properties page

  8. 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 NameData TypeDefault Value
    ApplicationSystem.StringHotelApp
    EnableAuthenticationSystem.BooleanTrue
    HostSystem.StringHotelAppHost

  9. 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.

Figure 6. Connection Properties page


Figure 7. HotelAdapter generated project


Tables 3 to 7 give a brief description of the files generated by the wizard.

Table 3. Connection Group

FileDescription
HotelAdapterConnection.csContains the definition of the class implementing the IConnection interface. This class is responsible for a single connection to the target LOB system.
HotelAdapterConnectionFactory.csContains 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.csContains the definition of the class representing connection string to the target LOB system.

Table 4. Metadata Handlers Group

FileDescription
HotelAdapterMetadataBrowseHandler.csContains the definition of the class implementing the IMetadataBrowseHandler interface. This class is responsible for the metadata browse capabilities of the adapter.
HotelAdapterMetadataResolverHandler.csContains 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.csContains 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

FileDescription
HotelAdapterHandlerBase.csContains the definition of the base class for adapter handlers.
HotelAdapterInboundHandler.csContains 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.csContains 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

FileDescription
HotelAdapterBinding.csContains 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.csContains the definition of the class used to register the adapter with WCF.
HotelAdapterBindingElement.csThis class is used to apply configuration properties to the adapter binding.
HotelAdapterBindingElementExtensionElement.csContains 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

FileDescription
HotelAdapter.csContains the definition of the main adapter class derived from Microsoft.ServiceModel.Channels.Common.Adapter.
HotelAdapterTrace.csContains 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.