Search
Windows Server

BizTalk 2009 : WCF LOB Adapter SDK (part 6)

Published 3 min readBy Programming4us Editorial Team

6. Step 6: Deployment

To make the HotelAdapter available for consumption by the client applications, you have to deploy it. The deployment procedure is not complicated. First you have to GAC the adapter by signing the adapter's assembly with a strong name key and calling the gacutil.exe utility with the /if switch. Second, you have to register the adapter with WCF by making a few entries in the machine.config file. Here is the process to follow to register the HotelAdapter with WCF:

  1. Go to the <%WINDIR%>\Microsoft.NET\Framework\Config folder, locate the machine.config file, and open it in Visual Studio.

  2. Update the <system.serviceModel> configuration section to include the HotelAdapter entries as follows:

    Code View: Scroll / Show All

    <system.serviceModel>
    <system.serviceModel>
    <client>
    <endpoint binding="hotelBinding" contract="IMetadataExchange"
    name="hotel" />
    </client>
    <extensions>
    <bindingElementExtensions>
    <add name="HotelAdapter"
    type="HotelApp.HotelAdapter.HotelAdapterBindingElementExtension,
    HotelApp.HotelAdapter.HotelAdapter,Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=XXXXXXXXXXXXX" />
    </bindingElementExtensions>
    <bindingExtensions>
    <add name="hotelBinding"
    type="HotelApp.HotelAdapter.HotelAdapterBindingCollectionElement,
    HotelApp.HotelAdapter.HotelAdapter,Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXX" />/>
    </bindingExtensions>
    </extensions>
    </system.serviceModel>


7. Step 7: Consuming from an .NET Application

Now that you have finished the deployment, the HotelAdapter can be consumed from the WCF-enabled client applications. You have to generate a proxy and update the app.config file to include the adapter configuration. The Add Adapter Service Reference plug-in is your main tool to do the job.

Here is the process to follow:

  1. Open Visual Studio, and create new project called ConsumeAdapterApplication.

  2. In the Solution Explorer, right-click the ConsumeAdapterApplication project, and select the Add Adapter Service Reference menu item.

  3. In the Select Binding combo box, select hotelBinding. Click the Configure button. The Configure Adapter dialog box will open.

  4. Specify the username and password, as shown in Figure 11. Click the OK button to return to the Add Adapter Service Reference plug-in.

  5. Click the Connect button. Make sure that the connection status has changed to "connected."

  6. In the "Select a category" list, select "Hotel operations."

  7. In the "Available categories and operations" list, select Get Rooms, and click the Add button. The Add Adapter Service Reference window now should look like Figure 13.

    Figure 13. Add Adapter Service Reference window

  8. Click the OK button to generate a proxy file. The app.config file will also be updated. Note that the proxy file named HotelAdapterBindingClient.cs is now part of the solution.

  9. Open the Program.cs file, and replace content with the following code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsumeAdapterApplication
    {
    class Program
    {
    static void Main(string[] args)

    {
    HotelServiceClient client = new HotelServiceClient();
    client.ClientCredentials.UserName.UserName = "Probiztalk2009";
    string response = client.GetRooms("Indigo hotel");
    Console.WriteLine(response);
    Console.Read();
    }
    }
    }

  10. Build and run the application. You will see the HotelAdapter response, as shown in Figure 14.

    Figure 14. The HotelAdapter response

8. Step 8: Consuming from BizTalk Application

To consume the HotelAdapter from a BizTalk application, you have to generate the schemas for the operations supported by the adapter and the binding file to create physical ports. In case of a BizTalk application, the tool to do the job is the Consume Adapter Service add-in. This tool has the same UI as the Add Adapter Service Reference plug-in, but it generates different artifacts.

Here is the process to follow:

  1. In Visual Studio, open your BizTalk project.

  2. In Solution Explorer, right-click the project, and select Add => Add Generated Items => Consume Adapter Service.

  3. In the Select Binding box, select hotelBinding. Click the Configure button. The Configure Adapter dialog box will open.

  4. Specify the username and password. Click the OK button to return to the Add Adapter Service Reference window.

  5. Click the Connect button. Make sure that the connection status has changed to "connected."

  6. In the "Select a category" list, select "Hotel operations."

  7. In the "Available categories and operations" list, select Get Rooms, and click the Add button.

  8. Click OK to generate the schemas and the binding file. The schema file named HotelAdapterBindings.xsd contains message definitions for the HotelAdapter request and response messages, as shown in Figure 15.

    Figure 15. Generated schema definitions

  9. Implement your project orchestration to communicate with the HotelAdapter through a request-response port. Your orchestration should look like Figure 16.

  10. Build and deploy the project.

  11. Open the BizTalk Administration Console.

  12. Import the binding file to create physical ports. Right-click your application under the Applications group, select Import => Bindings, navigate to your binding file, and click the Open button.

  13. Map the orchestration logical ports to the newly created physical ports.

  14. Enlist and start your orchestration.

  15. Start your application.

Figure 16. HotelAdapter orchestration