无法在 EWS API 中创建抽象类的实例

问题描述 投票:0回答:1

我创建了这个服务并使用了这个包:https://github.com/gautamsi/ews-js-api-browser Angular

import { Injectable } from '@angular/core';
import { ExchangeCredentials, ExchangeService, ItemSchema, ItemView, SearchFilter, Uri, WellKnownFolderName } from 'ews-js-api-browser';

@Injectable({
  providedIn: 'root'
})
export class ExchangeService {

  constructor( { }

  getData() {
     const service = new ExchangeService();
     service.Credentials = new ExchangeCredentials('username', 'password');
     service.Url = new Uri('.....Exchange.asmx');
  }
}

出现这个错误:

Cannot create an instance of an abstract class.ts(2511)
(alias) abstract new ExchangeCredentials(): ExchangeCredentials 

在这一行

service.Credentials = new ExchangeCredentials('username', 'password');
angular exchangewebservices ews-managed-api
1个回答
0
投票

通过查看文档,您可以看到他们正在使用这个抽象类的实现,在这种情况下

WebCredentials
.

你应该试试这个:

service.Credentials = new WebCredentials('username', 'password');

这个类的实现貌似不少。其中一些是:

WebCredentials
ClientCertificateCredentials
OAuthCredentials
WSSecurityBasedCredentials
。您应该使用最适合您的用例的那个。

© www.soinside.com 2019 - 2024. All rights reserved.