在本指南之后,我试图设置一个简单的通知服务:https://github.com/CumberlandGroup/node-ews
我在公司交换服务器后面,但是从交换团队那里获得了EWS详细信息,并且已经成功尝试发送邮件并列出DL用户(https://github.com/CumberlandGroup/node-ews)
但是,我无法使通知服务正常工作。 我以为是因为notification-wsdl配置不正确,但是我对SOAP和xml还是个新手。
testLst = myTest.getValues();
没有显示错误。
我下载的wsdl文件
// specify listener service options
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
const fs = require('fs')
const EWS = require('node-ews');
const serviceOptions = {
port: 8000, // defaults to port 8000
path: '/notification', // defaults to '/notification'
// If you do not have NotificationService.wsdl it can be found via a quick Google search
xml:fs.readFileSync('NotificationService.wsdl', 'utf8') // the xml field is required
};
const ewsConf = {
username: 'myuser',
password: 'mypass',
host: 'https://mail.mydomain.com'
};
// initialize node-ews
const ews = new EWS(ewsConf);
ews.auth.toString = ()=>'auth';
// create the listener service
ews.notificationService(serviceOptions, function(response) {
console.log(SendNotificationResult)
console.log(new Date().toISOString(), '| Received EWS Push Notification');
console.log(new Date().toISOString(), '| Response:', JSON.stringify(response));
// Do something with response
return {SendNotificationResult: { SubscriptionStatus: 'OK' } }; // respond with 'OK' to keep subscription alive
// return {SendNotificationResult: { SubscriptionStatus: 'UNSUBSCRIBE' } }; // respond with 'UNSUBSCRIBE' to unsubscribe
}).then(server => {
server.log = function(type, data) {
console.log(new Date().toISOString(), '| ', type, ':', data);
};
});
// create a push notification subscription
// https://msdn.microsoft.com/en-us/library/office/aa566188
const ewsConfig = {
PushSubscriptionRequest: {
FolderIds: {
DistinguishedFolderId: {
attributes: {
Id: 'inbox'
}
}
},
EventTypes: {
EventType: ['ModifiedEvent']
},
StatusFrequency: 1,
// subscription notifications will be sent to our listener service
URL: 'http://' + require('os').hostname() + ':' + serviceOptions.port + serviceOptions.path
}
};
ews.run('Subscribe', ewsConfig);