0

我有一个 ASP.Net MVC(框架版本 4.6.2)网站,我试图通过 API 整合我们 Bing Ads 活动的每日费用总额。

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

会发生什么:

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

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

var client = new ReportingServiceClient();

我不确定如何进行。我的 .config 文件中确实没有配置端点。我本来希望 Nuget 添加必要的配置,但什么都没有。我不知道为什么它没有,或者我应该添加到我的 .config 中。

4

1 回答 1

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 Docs的示例 Web 解决方案。我建议您还查看GitHub中使用ReportingServiceManager的这个示例。

另请注意,我安装了 System.ServiceModel.Primitives 4.4.1、System.ServiceModel.Http 4.4.1 和 System.ServiceModel.ConfigurationManager 4.4.1(几周前遇到了其他一些版本的问题),如此处所述

我希望这有帮助!

于 2018-05-04T19:52:58.227 回答