Provide OData Services of Adobe Target Data from a WCF Application



In this article, we will demonstrate the process of generating an OData feed for Adobe Target data by developing a WCF Service Application.

The CData ADO.NET Provider for Adobe Target enables you to rapidly develop service-oriented applications using the Windows Communication Foundation (WCF) framework, providing Adobe Target data data to OData consumers. This article guides you through creating an entity data model for connectivity and a WCF Data Service to expose OData services. You can then consume the feed with various OData clients, such as Power Pivot or applications using the CData ADO.NET Provider for OData.

Create the OData Service

Follow the steps below to create a WCF service application that will provide connectivity to Adobe Target data via OData.

  1. Open Visual Studio and create a new project. Select the WCF Service Application template.
  2. Delete the autogenerated IService.cs and Service1.svc.
  3. Install Entity Framework 6:

    Use the Package Manager Console in Visual Studio to install the latest version of Entity Framework. Run the following command to download and install Entity Framework automatically:

    Install-Package EntityFramework
  4. Register the Entity Framework provider:
    1. Add the following provider entry in the "providers" section of your App.config or Web.config file. This section should already exist if the Entity Framework installation was successful.
      <configuration>
      ...
      <entityFramework>
        <providers>
          ...
          <provider invariantName="System.Data.CData.AdobeTarget" type="System.Data.CData.AdobeTarget.AdobeTargetProviderServices, System.Data.CData.AdobeTarget.Entities.EF6" />
        </providers>
      </entityFramework>
      </configuration>
    2. Add a reference to System.Data.CData.AdobeTarget.Entities.dll, located in lib/4.0 in the installation directory.
    3. Build the project to complete the setup for using EF6.
  5. Click Project -> Add New Item -> ADO.NET Entity Data Model.
  6. In the Entity Data Model wizard that is displayed, select the 'EF Designer from Database' option.
  7. In the resulting Choose Your Connection dialog, click New Connection.
  8. In the Connection properties dialog, select the CData Adobe Target Data Source and enter the necessary credentials.

    A typical connection string is below:

    Tenant=mycompanyname;InitiateOAuth=GETANDREFRESH

    To connect to Adobe Target, you must provide the Tenant property along with OAuth connection properties mentioned below. Note that while other connection properties can influence processing behavior, they do not affect the ability to connect.

    To determine your Tenant name:

    1. Log in to Adobe Experience. The URL will look similar to: "https://experience.adobe.com/#/@mycompanyname/preferences/general-section".
    2. Extract the value after the "/#/@". In this example, it is "mycompanyname".
    3. Set the Tenant connection property to that value.

    User Accounts (OAuth)

    You must set AuthScheme to OAuthClient for all user account flows.

    Note: Adobe authentication via OAuth requires updating your token every two weeks.

    All Applications

    CData provides an embedded OAuth application that simplifies OAuth authentication. Alternatively, you can create a custom OAuth application. Review Creating a Custom OAuth App in the Help documentation for more information.

    Obtaining the OAuth Access Token

    Set the following properties to connect:

    • InitiateOAuth: Set to GETANDREFRESH to automatically perform the OAuth exchange and refresh the OAuthAccessToken as needed.
    • OAuthClientId : Set to the client Id assigned when you registered your app.
    • OAuthClientSecret : Set to the client secret assigned when you registered your app.
    • CallbackURL : Set to the redirect URI defined when you registered your app. For example: https://localhost:3333

    With these settings, the provider obtains an access token from Adobe Target, which it uses to request data. The OAuth values are stored in the location specified by OAuthSettingsLocation, ensuring they persist across connections.

  9. Select Adobe Target tables and views that you want OData clients to access.
  10. Click Project -> Add New Item -> WCF Data Service.
  11. Specify the data source class and configure access to the new WCF Data Service. In the example below, the Access Rule for the entities is set to All. This means that any user will be able to read and modify data.

      
    using System;
    using System.Collections.Generic;
    using System.Data.Services;
    using System.Data.Services.Common;
    using System.Linq;
    using System.ServiceModel.Web;
    using System.Web;
    
    namespace AdobeTargetService{
      public class AdobeTargetDataService : DataService<AdobeTargetEntities> {
        public static void InitializeService(DataServiceConfiguration config) {
          config.SetEntitySetAccessRule("*", EntitySetRights.All);
          config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
        }
      }
    }
    	
  12. Run the project. Applications that support OData can now access the Salesforce data and reflect any changes. You can access the feed in your browser. The feed will resemble the following:

Consume the OData Service from Power Pivot

You can now use the service from any OData client; for example, Excel Power Pivot.

  1. Open Excel and click on the Power Pivot Window button.
  2. A new pop-up will appear. Select the option From Data Feeds.
  3. In the resulting Table Import Wizard, enter the OData URL. For example, http://localhost:12449/AdobeTargetDataService.svc/.
  4. After connecting to the OData service, click the Next button at the bottom of the window.
  5. A table listing of the available tables will appear in the next window of the wizard. Select which tables you want to import and click Finish.
  6. Click Close to import the data in Power Pivot.

Ready to get started?

Download a free trial of the Adobe Target Data Provider to get started:

 Download Now

Learn more:

Adobe Target Icon Adobe Target ADO.NET Provider

Easily connect .NET applications with real-time data. Use Adobe Target to manage the data that powers your applications.