开发者

Testing Exchange Web Service (EWS) url

I have UI where I have the user enter the Url where I can find the Exchange Web Service(EWS). My application uses EWS to get Free/Busy information but my configuration tool just needs to set it for the user.

For now I am just asking for the host name and building up the Url from there. For example they enter example.org as the host and I build https://example.org/EWS/Exchange.asmx from that.

I would like to add a test button to ensure the host they entered is reachable by the machine they are configuring. But I'm not sure how simple or complex I need to be to test the service.

Is there any noop or bind I can do to make sure I can establish communication with EWS?

Something like:

var serviceUri = new Uri(_textBoxEwsUrl.Text));
var exchangeService = new ExchangeService();
exchangeService.Url = serviceUri;

// what can I call here开发者_如何学Go to test that I can talk to the exchangeService?
exchangeService.????


Bind to the inbox folder of the users mail address. Of course, you would need his credentials to this.


Any kind of operation that results in communication with server can be used as test. Simple binding to any folder or item will throw ServiceRequestException or some different type of exception if your url or credentials are incorrect.

Sample code:

try
{
    var inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
}
catch(ServiceRequestException e)
{
    //handle exception in some way
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜