How to: Add an Association Between Two Web Service-Based External Content Types

Applies to: SharePoint Server 2010

This walkthrough demonstrates how to create an association between two external content types that are based on a Web service. This walkthrough uses the Code Sample: AdventureWorks2008 ASP.NET Web Service and requires that you have already created two external content types and their basic operations. The two required external content types are:

  • Customer External Content Type: Identifier: CustomerId.

  • Order External Content Type: Identifier: OrderId, Foreign Key: CustomerId.

The CustomerId identifier relates the orders to the customers.

To add a Web Service-based association

  1. Create the association on the appropriate Web method that corresponds to the related external content type that has the foreign key. (You should have already created the external content type and defined the basic operations for it.) This Web method is one of the operations defined for the external content type. In this example, create the association on the Order external content type.

    To create the association, in the External Content Types page in SharePoint Designer, double-click the Order external content type.

  2. On the ribbon, click Operations Design View.

  3. In the Data Source Explorer, locate the GetOrdersForCustomer method. Right-click the method, and then click New Association. This creates an Association method instance on the Order external content type, as shown in Figure 1.

    Figure 1. New Web Service-based association

    New WCF-based association

  4. In the Association Properties dialog box, click the Browse button, as shown in Figure 2.

    Select the external content type as Customer. Notice that the common identifier field (CustomerId) is displayed for both external content types, as shown in Figure 2. Click Next.

    Figure 2. Matching identifiers of the external content types

    Matching identifiers of the external content types

  5. On the Input Parameters Configuration page, select CustomerId from the Data Source Elements pane. In the Properties pane, click Map to Identifier, and then select CustomerId from the Identifier list, as shown in Figure 3.

    Figure 3. Define input parameters for the association

    Define input parameters for the association

  6. Click Next to go to the Return Parameter Configuration page.

    Select CustomerId from the Identifier drop-down list, as shown in Figure 4.

    Figure 4. Configure return parameters for the association

    Configure return parameters for the association

  7. Click Finish to create an operation named GetOrdersForCustomer.

  8. Save the external content type, and then generate the external lists for both external content types. Now, from the external list, you can connect to Microsoft Outlook, or SharePoint Workspace.

    You will automatically see an external content type instance picker next to each customer in the Order forms in SharePoint Server, Outlook and Microsoft SharePoint Workspace.

  9. To view the association you just created, create a profile page for the subcategory. Figure 5 shows a profile page.

    Figure 5. All orders related to a specific customer

    All products related to a specific subcategory