Connect Workday to your favorite reporting tools without moving data.
Learn More →Provide OData Services of Twilio Data from a WCF Application
This article shows how to publish an OData feed of Twilio data by creating a WCF Service Application.
The CData ADO.NET Provider for Twilio enables you to use the Windows Communication Foundation (WCF) framework to rapidly develop service-oriented applications that provide Twilio data to OData consumers. This article shows how to create an entity data model to provide the underlying connectivity to the Twilio data, as well as how to create a WCF Data Service to expose the OData service. You can then consume the feed with any OData client, for example, Power Pivot or an application that uses 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 Twilio data via OData.
- Open Visual Studio and create a new project. Select the WCF Service Application template.
- Delete the autogenerated IService.cs and Service1.svc.
- 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
- Register the Entity Framework provider:
- 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.Twilio" type="System.Data.CData.Twilio.TwilioProviderServices, System.Data.CData.Twilio.Entities.EF6" /> </providers> </entityFramework> </configuration>
- Add a reference to System.Data.CData.Twilio.Entities.dll, located in lib/4.0 in the installation directory.
- Build the project to complete the setup for using EF6.
- 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.
- Click Project -> Add New Item -> ADO.NET Entity Data Model.
- In the Entity Data Model wizard that is displayed, select the 'EF Designer from Database' option.
- In the resulting Choose Your Connection dialog, click New Connection.
In the Connection properties dialog, select the CData Twilio Data Source and enter the necessary credentials.
A typical connection string is below:
AccountSid=MyAccountSid;AuthToken=MyAuthToken;
Use the AccountSid and AuthToken connection properties to access data from your account. You obtain your live credentials on your Twilio account dashboard. Click Account -> Account Settings to obtain your test credentials.
- Select Twilio tables and views that you want OData clients to access.
- Click Project -> Add New Item -> WCF Data Service.
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 TwilioService{ public class TwilioDataService : DataService<TwilioEntities> { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3; } } }
-
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.
- Open Excel and click on the Power Pivot Window button.
- A new pop-up will appear. Select the option From Data Feeds.
- In the resulting Table Import Wizard, enter the OData URL. For example, http://localhost:12449/TwilioDataService.svc/.
- After connecting to the OData service, click the Next button at the bottom of the window.
- 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.
- Click Close to import the data in Power Pivot.