今すぐお試しください!

製品の詳細CData ADO.NET Provider for PCA Accounting を確認して、無償評価版をダウンロード:

今すぐダウンロード

Provide OData Services of PCA Accounting Data from a WCF Application

This article shows how to publish an OData feed of PCA Accounting data by creating a WCF Service Application.

The CData ADO.NET Provider for PCA Accounting enables you to use the Windows Communication Foundation (WCF) framework to rapidly develop service-oriented applications that provide PCA Accounting data to OData consumers. This article shows how to create an entity data model to provide the underlying connectivity to the PCA Accounting 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 PCA Accounting 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. Click Project -> Add New Item -> ADO.NET Entity Data Model.
  4. In the Entity Data Model wizard that is displayed, select the 'EF Designer from Database' option.
  5. In the resulting Choose Your Connection dialog, click New Connection.
  6. In the Connection properties dialog, select the CData PCA Accounting Data Source and enter the necessary credentials. A typical connection string is below:

    OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:33333;ProductCode=MyProductCode;ApiVersion=V1;DataCenter=DataCenterName;DefaultDataArea=MyDefaultDataArea;InputModuleName=DefaultInputModuleName;

    PCA クラウド会計DX では、OAuth 2 認証標準を使います。

    ユーザー資格情報の接続プロパティを設定せずに接続できます。接続に最小限必要な接続プロパティは、次のとおりです。

    • InitiateOAuth:GETANDREFRESH に設定。InitiateOAuth を使って、OAuth 交換や、手動での接続文字列のアクセストークン設定の繰り返しを避けられます。
    • OAuthClientId:アプリケーション設定のクライアントId に設定。
    • OAuthClientSecret:アプリケーション設定のクライアントシークレットに設定。
    • CallbackURL:アプリケーション設定のリダイレクトURL に設定。
    • ApiVersion:接続するPCA API Server バージョンを設定。
    • DefaultDataArea:接続するデータ領域を設定。
    • DataCenter:接続するサーバーのDataCenter 名を設定。
    • ProductCode:PCA 製品コード名を設定。
    • InputModuleName:PCA InputSlip のInputModuleName を設定。

    接続すると、本製品 はデフォルトブラウザでPCA Accounting OAuth エンドポイントを開きます。ログインして、本製品 にアクセス許可を与えます。本製品 がOAuth プロセスを完了します。

    ヘッドレスマシンの認証など、他のOAuth 認証フローについては、OAuth 認証の使用 を参照してください。

    See the help documentation for guides to connecting in Visual Studio.

  7. Select PCA Accounting tables and views that you want OData clients to access.
  8. Click Project -> Add New Item -> WCF Data Service.
  9. 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 PCAAccountingService{ public class PCAAccountingDataService : DataService { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3; } } }
  10. 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/PCAAccountingDataService.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.
 
 
ダウンロード