Closed tdhulster closed 8 years ago
I removed his wsdlFix variable from the file ews.js on line 137 which seemed to fix that error... but then you get "Cannot set property 'descriptions' of null" ... can the author provide guidance?
Please try the 2.0.0-dev branch and see if that resolves issues. Note this is a major rewrite and some command syntax is different.
I'm seeing the same issue with getting out of office.
Do you think 2.0.0 will address that? When do you expect 2.0.0 to be prod?
Hi, I was testing the 2.0.0-dev branch and I did the changes for the auth config, but now I just get a timeout when I am trying to use the GetUserOofSettings. Any idea?
Thanks
Ok, seems that my eclipse was doing something bad.. I don't have the timeouts anymore but then I get this:
Potentially unhandled rejection [1] Unexpected root element of WSDL or include (WARNING: non-Error used)
When I was getting this error it was due to bad credentials which resulted in an empty wsdl.
I discovered this by adding some console.logs to the getFile function in the init section of the ews.js file:
// get file via ntlm
function getFile(url, file) {
console.log("Getting file with NTLM:",url + " => "+file);
ntlmOptions.url = url;
return when.promise((resolve, reject) => {
ntlm.get(ntlmOptions, function (err, res) {
if(err) reject(err);
else {
console.log("NTLM Response:",res);
fs.writeFile(file, res.body, function(err) {
if(err) reject(err);
else resolve(file);
});
}
});
});
}
Which gave me this:
Getting file with NTLM: https://mail.myserver.com/ews/messages.xsd => C:\Users\User\AppData\Local\Temp\tmp-158643EJsCnueZILs\messages.xsd NTLM Response: { headers: { server: 'Microsoft-IIS/8.5', 'request-id': '893482fc-e028-4a70-9849-69b180aead50', 'set-cookie': [ 'ClientId=HWJBHGUUDMZDHEG; expires=Sat, 02-Sep-2017 13:55:29 GMT; path=/; HttpOnly' ], 'www-authenticate': 'Digest qop="auth",algorithm=MD5-sess,nonce="+Upgraded+v1df2307aceb4b9376e101b87e52e4e46d621a7aaa2105d2018aab30cae1825b44ae58230b54735fdc23c799d1e65532304d6c587e76689e5e",charset=utf-8,realm="Digest", Basic realm="mail.myserver.com", Negotiate, NTLM', 'x-powered-by': 'ASP.NET', 'x-feserver': 'MYMAILSERVER', date: 'Fri, 02 Sep 2016 13:55:29 GMT', connection: 'close', 'content-length': '0' }, statusCode: 401, body: '', cookies: [ 'ClientId=HACDHGUUVMZDHEG' ] }
Because of the error 401, the body of the NTLM was empty and as such the init script is simply appending the wdsl fix contents to an empty string which of course results in a malformed wdsl file.
I updated the getFile function to reject if the NTLM response code is 401 (unauthorized):
// get file via ntlm
function getFile(url, file) {
console.log("Getting file with NTLM:",url + " => "+file);
ntlmOptions.url = url;
return when.promise((resolve, reject) => {
ntlm.get(ntlmOptions, function (err, res) {
if(err) reject(err);
else {
if(res.statusCode==401) reject('NTLM StatusCode 401: Unauthorized.');
fs.writeFile(file, res.body, function(err) {
if(err) reject(err);
else resolve(file);
});
}
});
});
}
And added a check for the presence of an opening wsdl ('<wsdl:definitions') in the readFile of the init's return promise and if it doesn't exist then it will reject it:
// fix ms wdsl...
// https://msdn.microsoft.com/en-us/library/office/aa580675.aspx
// The EWS WSDL file, services.wsdl, does not fully conform to the WSDL standard
// because it does not include a WSDL service definition. This is because EWS is
// not designed to be hosted on a computer that has a predefined address.
return when.promise((resolve, reject) => {
fs.readFile(file, 'utf8', function(err, wsdl) {
if(wsdl.search('<wsdl:definitions')==-1) reject('Invalid or malformed wsdl file.\nFile: '+file);
if(err) reject(err);
else {
// break file into an array of lines
var wsdlLines = wsdl.split('\n');
// remove last 2 elements of array
wsdlLines.splice(-2,2);
// join the array back into a single string and apply fix
var newWsdl = wsdlLines.join('\n') + wsdlFix;
// write file back to disk
fs.writeFile(file, newWsdl, function(err) {
if(err) reject(err);
else resolve(file);
});
}
});
})
After fixing my credentials this error was resolved, the files were retrieved and the proper wsdl was able to be used to create the client connection.
Thanks! I will review and look to roll this into the next patch.
The 2.1.0 update includes the additional error notifications suggested above by @kcastrotech
I keep getting this error - "Unexpected root element of WSDL or include" - when trying to create soap client, but I have no idea where I have to start looking to resolve this;
The response is gzipped though so I tried to add "wsdl_options: { gzip: true }" to the soap createClient options object without any luck. http://stackoverflow.com/questions/30139878/how-to-consume-wcf-in-node-js
Any idea what I can check/change to resolve this?