We can refer to the below mentioned articles for configuring and using EWS impersonation for the Exchange 2010:
And here are the links for configuring and using EWS impersonation for the Exchange 2007:
Hope this helps!!!