Bing Ads API:.config中的端点配置

时间:2018-05-04 13:24:39

标签: .net wcf bing-ads-api

我有一个ASP.Net MVC(框架版本4.6.2)网站,我正在尝试通过API整合Bing Ads广告系列中的每日费用总额。

我已经通过Nuget添加了包Microsoft.BingAds.SDK并针对其编译的类编写了一些代码,所以我想我可以启动它,看看会发生什么。

这是怎么回事:

  

找不到引用合同的默认端点元素   'Microsoft.BingAds.V11.Reporting.IReportingService'中   ServiceModel客户端配置部分。这可能是因为没有   找到了您的应用程序的配置文件,或者因为没有   匹配此合同的端点元素可以在客户端中找到   元件。

错误发生在ReportingServiceClient()的构造函数中:

var client = new ReportingServiceClient();

我不知道该怎么办。我的.config文件中确实没有配置端点。我本来期望Nuget添加必要的配置,但没有什么。我不知道它为什么没有,或者我应该添加到我的.config。

1 个答案:

答案 0 :(得分:0)

您是否有更多详细信息,例如您创建和使用服务客户端的代码段?您使用的是A)ReportingServiceManager还是B)ServiceClient?

AuthorizationData authorizationData = new AuthorizationData
{
    // By this point OAuthWebAuthCodeGrant already has 
    // access and refresh tokens
    Authentication = OAuthWebAuthCodeGrant,
    DeveloperToken = "DeveloperTokenGoesHere"
};

// Option A: ReportingServiceManager
ReportingServiceManager reportingServiceManager = new ReportingServiceManager(authorizationData);

// Option B: ServiceClient<IReportingService>
ServiceClient<IReportingService> service = new ServiceClient<IReportingService>(authorizationData);

以下是API文档中的example web solution。我建议您还审核使用this example from GitHubReportingServiceManager

另请注意,我安装了System.ServiceModel.Primitives 4.4.1,System.ServiceModel.Http 4.4.1和System.ServiceModel.ConfigurationManager 4.4.1(几个星期前与其他一些版本一起遇到的问题){{{ 3}}

我希望这有帮助!