none
[E2010] [EWSMA] [C#] Issues while using EWSMA from another service RRS feed

  • General discussion

  • EWS Managed API SDK is more suited for thick clients. While working with EWSMA in WCF services, I encountered the following inconveniences:

    1. Types like EmailMessage, Item do not have a default constructor and cannot be serialized using DataContractSerializer or XmlSerializer.
    2. It is not possible to retrieve the associated Service object like Item, Message from corresponding EWSMA types like Item, EmailMessage. I had to generate proxies from EWS SDK and manually copy the properties from EWSMA to EWS SDK objects
    3. The Subscription model exposed by EWSMA is more suited for stateful clients. In stateless clients, like another web service, we cannot store the subscription object, But we should be able to recrreate it somehow. Recreating with watermarks is very inconsistent.

    • Edited by vijayst Wednesday, October 19, 2011 10:14 AM
    Wednesday, October 19, 2011 10:13 AM

All replies

  • Hi,

    1. Yes, serialization is not possible. You'll either have to store the data somewhere else or just store the ItemIds and fetch the details again from the Exchange server when required.

    2. Why do you want to access the webservice objects?

    3. When you are working in a stateless environment, don't use subscriptions. Instead, use the SyncFolderItems method.
     Kind regards,
    Henning

    If you get your question answered, please come back and mark the reply as an answer.
    If you are helped by an answer to someone else's question, please mark it as helpful.

    Wednesday, October 19, 2011 11:46 AM
  • I am creating another web service that will expose objects from EWS SDK. If I could get the Service object from EWSMA object, I do not have to manually copy the code from EWSMA objects to EWS SDK objects.
    Wednesday, October 19, 2011 11:49 AM
  • Unfortunately, this is no option.. you'll have to copy the values.

    Maybe something like AutoMapper can help you here: https://github.com/AutoMapper/AutoMapper
     Kind regards,
    Henning

    If you get your question answered, please come back and mark the reply as an answer.
    If you are helped by an answer to someone else's question, please mark it as helpful.

    Wednesday, October 19, 2011 11:56 AM
  • I doubt if automapper will help. The properties within EWSMA throw a ServiceObjectPropertyException. If such an exception is thrown, I will have to set the associated property XXXSpecified to false. For eg.

     

                   try
                    {
                        messageType.DateTimeCreated = message.DateTimeCreated;
                        messageType.DateTimeCreatedSpecified = true;
                    }
                    catch (ServiceObjectPropertyException)
                    {
                        messageType.DateTimeCreatedSpecified = false;
                    }
    

     


    • Edited by vijayst Wednesday, October 19, 2011 1:38 PM
    Wednesday, October 19, 2011 1:37 PM
  • Yes... you are right.

    Kind regards,
    Henning

    If you get your question answered, please come back and mark the reply as an answer.
    If you are helped by an answer to someone else's question, please mark it as helpful.

    Wednesday, October 19, 2011 1:44 PM