Setting the Exchange service URL by using the EWS Managed API
To use the Microsoft Exchange Web Services (EWS) Managed API, you must set the Exchange Service URL. You can provide the appropriate service binding manually, or by using the AutodiscoverUrl method. The AutodiscoverUrl method initializes the Url property to the Exchange Web Services URL for the specified email address by calling the Autodiscover service.
We recommend that you use the Autodiscover service because the Autodiscover service determines the best endpoint for a specific user. When you use the Autodiscover service, if the EWS URL changes, your code will not be affected.
For information about compiling this code, see Getting started with the EWS Managed API.
-
Write appropriate error handling code for common search errors.
-
Review the client request XML sent to the Exchange server.
-
Review the server response XML sent from the Exchange server.
-
Set the service binding as shown in Setting the Exchange service URL by using the EWS Managed API. Do not hard code URLs because if mailboxes move, they might be serviced by a different Client Access server. If the client cannot connect to the service, retry setting the binding by using the AutodiscoverUrl method.
-
Use HTTP with SSL for all communication between client and server.
-
Always validate the server certificate that is used for establishing the SSL connections. For more information, see Validating X509 certificates.
-
Do not include user names and passwords in trace files.
-
Autodiscover lookups that use HTTP GET to find an endpoint should always prompt for user confirmation; otherwise, they should be blocked.