无效的SOAP请求

时间:2019-03-26 01:05:49

标签: reactjs ews-javascript-api

我正在尝试使用Microsoft的EWS从日历事件中获取事件列表。这是一项要求,我不能使用图形API。

由于我的应用当前基于react构建,所以我想找到一个插件来帮助我简化与服务器通信的过程,我发现https://github.com/gautamsi/ews-javascript-api

这是我的代码,请考虑到我将其用于reactjs。

我已经安装了cors插件来克服cors阻塞,但是仍然可以

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://outlook.office365.com/Ews/Exchange.asmx with MIME type text/xml. See https://www.chromestatus.com/feature/5629709824032768 for more details.

我不确定这是否是一个问题,但请仔细阅读,这似乎不是问题的原因。

这是调用交换服务的代码库。

componentWillMount() {
    let exch = new ExchangeService();
    exch.Credentials = new ExchangeCredentials(some_email, some_pwd);
    exch.Url = new Uri("https://outlook.office365.com/Ews/Exchange.asmx");

    var view = new CalendarView(DateTime.Now.Add(-10, "week"), DateTime.Now);
    exch.FindAppointments(WellKnownFolderName.Calendar, view).then((response) => {
      console.log(response);
      let appointments = response.Items;
      let appointment = appointments[0];
      console.log("Subject: " + appointment.Subject);
      console.log("Start Time: " + appointment.Start);
      console.log("End Time: " + appointment.End);
      console.log("Recipients: ");
      appointment.RequiredAttendees.Items.forEach((a) => {
        console.log(a.Address);
      });
      console.log("unique id: " + appointment.Id.UniqueId, true, true);
    }, function (error) {
      console.log(error);
    });
  }

我目前正在研究一个全新的create-react-app,并在将其合并到我的主要代码库之前将其打印出来。

我得到的错误是

"Error: invalid soap message
    at FindItemRequest.ServiceRequestBase.ReadResponseXmlJsObject (http://localhost:3000/static/js/0.chunk.js:62630:13)
    at FindItemRequest.SimpleServiceRequestBase.ReadResponsePrivate (http://localhost:3000/static/js/0.chunk.js:63833:34)
    at http://localhost:3000/static/js/0.chunk.js:63785:41
    at tryCatcher (http://localhost:3000/static/js/0.chunk.js:6751:25)
    at Promise._settlePromiseFromHandler (http://localhost:3000/static/js/0.chunk.js:4621:35)
    at Promise._settlePromise (http://localhost:3000/static/js/0.chunk.js:4687:20)
    at Promise._settlePromise0 (http://localhost:3000/static/js/0.chunk.js:4737:16)
    at Promise._settlePromises (http://localhost:3000/static/js/0.chunk.js:4833:20)
    at http://localhost:3000/static/js/0.chunk.js:1326:23"

package.lock文件为

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "ews-javascript-api": "^0.9.4",
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-scripts": "2.1.8"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

我已经在React Web应用程序上构建了它一次,没有遇到任何问题。但是,当我尝试将代码推送到主代码库中时,出现了Cannot find module 'net'错误。因此,在尝试继续之前,我尝试将其推送到一个干净的代码库中,然后看看这样做无济于事。

任何帮助都会很棒!

0 个答案:

没有答案