ews-javascript-api icon indicating copy to clipboard operation
ews-javascript-api copied to clipboard

Access raw response

Open anujkumar-df opened this issue 8 years ago • 6 comments
trafficstars

Hi Gautam,

Is there any way to access raw response sent by exchange ?

anujkumar-df avatar May 26 '17 03:05 anujkumar-df

You can modify servicerequestbase.ts to create a hook there. Or better create a callback in ewsservicexmlreader.ts where the xml is transformed.

gautamsi avatar May 26 '17 05:05 gautamsi

If you can give some pseudo code, that would be great. I mean where you put callback, etc.

anujkumar-df avatar May 26 '17 16:05 anujkumar-df

if you are not in hurry, I can add this as feature request.

gautamsi avatar May 27 '17 05:05 gautamsi

Well tbh, I have a deadline to meet :), so if you can provide me a pseudo code, it would be great and I can perhaps create a PR in lets say few days.

anujkumar-df avatar May 27 '17 05:05 anujkumar-df

take a look at XHRDefaults.ts files. you can add a static/instance field registering callbbacks like this

class XHRDefaults{
static EWSCallBacks:Fucntion[] = [];
//------ other code
// - -- in function XHR: before line ---- resolve(setupXhrResponse(xhrResponse));
if(XHRDefaults.EWSCallBacks && EWSCallBacks.length >0){
  //other validations
  XHRDefaults.EWSCallBacks.foreach(cb=>{
       cb(xhrResponse.response)
  });
}
}

register callback when you import ews - before creating any instance of service.

var ews = require("ews-javascript-api");
ews.XHRDefaults.EWSCallBacks.push(function(raw){console.log(raw)});

does this help?

that would still be non optimal solution, EWS has some mechanism of writing tracing adapters which you can track in #80

gautamsi avatar May 27 '17 05:05 gautamsi

when you use instance field, you have to get the XHRApi property from ExchangeService instance.

var ews = require("ews-javascript-api")
var svc = new ews.ExchangeService(params);
svc.XHRApi.EWSCallBacks.push(fucntion_Call);

gautamsi avatar May 27 '17 06:05 gautamsi