Need a way to find Exchange product version by using EWS web service (SOAP)

exchange web services c#
exchange web services 2016
exchange web services url
connect to exchange server using c#
send email using exchange web service c#
postman exchange ews
exchange web services autodiscover c#
microsoft.exchange.webservices nuget

I am trying to get Exchange product version for different servers. The servers are hosted by Microsoft, Clients or third party service providers. I need a way to find the version - so I can use correct schema and version specified operations (like "Get Password Expiration" introduced in Exchange2010_SP2). The min product version supported is "Exchange2007". The soap request I send to server to retrieve the version is below.

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2007_SP1" />
  </soap:Header>
  <soap:Body>
    <GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <FolderShape>
        <t:BaseShape>Default</t:BaseShape>
      </FolderShape>
      <FolderIds>
        <t:DistinguishedFolderId Id="sentitems" />
      </FolderIds>
    </GetFolder>
  </soap:Body>
</soap:Envelope>

The problem for this request is the returned server versions are vary and not clearly shows the Exchange product version. The version values I got are something like 'V2_68', 'V2015_10_05'. I have failed to match these values to Exchange product version as the values are not stable.

I have tried to use AutoDiscover GetUserSettingsResponseMessage operation. For some servers this operation can return schemas in tag EwsSupportSchemas. But not all servers support AutoDiscover.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover"      
               xmlns:wsa="http://www.w3.org/2005/08/addressing" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <a:RequestedServerVersion>Exchange2010</a:RequestedServerVersion>
    <wsa:Action>http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetUserSettings</wsa:Action>
    <wsa:To>https://myserver.contoso.com/autodiscover/autodiscover.svc</wsa:To>
  </soap:Header>
  <soap:Body>
    <a:GetUserSettingsRequestMessage xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover">
      <a:Request>
        <a:Users>
          <a:User>
            <a:Mailbox>UserName@domain.contoso.com</a:Mailbox>
          </a:User>
        </a:Users>
        <a:RequestedSettings>
          <a:Setting>UserDisplayName</a:Setting>
          <a:Setting>UserDN</a:Setting>
          <a:Setting>UserDeploymentId</a:Setting>
          <a:Setting>InternalMailboxServer</a:Setting>
          <a:Setting>MailboxDN</a:Setting>
          <a:Setting>ActiveDirectoryServer</a:Setting>
          <a:Setting>CasVersion</a:Setting>
          <a:Setting>EwsSupportedSchemas</a:Setting>
        </a:RequestedSettings>
      </a:Request>
    </a:GetUserSettingsRequestMessage>
  </soap:Body>
</soap:Envelope>

Thank you so much.

You need to differentiate between OnPrem where the request your trying will work okay (eg you will see and Exchange Schema Version) and Office365 which is the only time you will get schema versions like 'V2_68', 'V2015_10_05' (this is because the cloud and OnPrem versions have diverged) and you should expect that will change as the update cadences in the cloud vary. There are lots of ways to determine if your accessing a cloud Mailbox from the autodiscover to just looking at the EndPoint your request are going to (eg on Office365 everything will go to the Load Balanced endpoint).

Cheers Glen

EWS applications and the Exchange architecture, How do I enable Exchange Web Services EWS on an SSL connection? EWS functionality in Exchange product versions. EWS implements new functionality in new product releases. Use the information in this article to determine whether the version of Exchange you're targeting includes support for the data or features you need access to.

EWS schema versions in Exchange, Find information to help you get started with EWS and other web services in Exchange. The web services in Exchange provide access to mailbox data stored in need to be familiar with in order to start using EWS and other web services in Exchange. EWS functionality in Exchange product versions Find reference information for the SOAP Autodiscover service in Exchange. The Autodiscover service provides the configuration information that your application uses to create a connection to an Exchange server. You can use the SOAP Autodiscover service to send messages between the client application and the Exchange server to locate the settings the application will use to connect to Exchange.

Exchange returns the server information in every response. You can do a dummy request and get the version from there. Using the EWS managed api library available here: https://github.com/OfficeDev/ews-managed-api

You can do the following:

   /// <summary>
        /// It returns the Exchange server version. It works for any Exchange version since 2007 SP1
        /// </summary>
        private ExchangeVersion GetExchangeVersion(Uri EWS_Url, ExchangeCredentials exchange_credentials=null)
        {

            // We pick the oldest version supported by the EWS library which is 2007 SP1
            // Newer exchange versions are backwards compatible
            ExchangeService exchange_service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
            exchange_service.Url = EWS_Url;

            if (exchange_credentials==null)
                exchange_service.UseDefaultCredentials = true;
            else
                exchange_service.Credentials = exchange_credentials;


            // We do a dummy call
            Folder exchange_folder;
            exchange_folder = Folder.Bind(exchange_service, WellKnownFolderName.Inbox);
            exchange_folder.Load();

            // Retrieve the server info returned in the last call
            ExchangeServerInfo server_info = exchange_service.ServerInfo;


            // This is based on the list from:
            // https://technet.microsoft.com/en-us/library/hh135098(v=exchg.150).aspx
            //
            if (server_info.MajorVersion == 8 && server_info.MinorVersion >= 1)
                return (ExchangeVersion.Exchange2007_SP1);
            else if (server_info.MajorVersion == 14 && server_info.MinorVersion == 0)
                return (ExchangeVersion.Exchange2010);
            else if (server_info.MajorVersion == 14 && server_info.MinorVersion == 1)
                return (ExchangeVersion.Exchange2010_SP1);
            else if (server_info.MajorVersion == 14 && server_info.MinorVersion >= 2)
                return (ExchangeVersion.Exchange2010_SP2);
            else if (server_info.MajorVersion == 15 && server_info.MinorVersion == 0)
                return (ExchangeVersion.Exchange2013);
            else if (server_info.MajorVersion >= 15)
                return (ExchangeVersion.Exchange2013_SP1);
            else
                throw (new Exception("Unknown Exchange version"));
        }

Start using web services in Exchange, SOAP APIs have a web service detection language (WSDL) that The best way to explain simple object access protocol APIs is to look at a real life example As you can see this WSDL file immediately looks complex, and that's because it is With Exchange EWS, you must specify a compatible version of  The operation reference information will help you to understand the structure of the XML that is included in the SOAP messages that are sent to and from the server. In this section. EWS operations in Exchange. EWS XML elements in Exchange. See also. Web services reference for Exchange; Explore the EWS Managed API, EWS, and web services in Exchange

Understanding APIs: SOAP, Quickly integrate EWS, EAS or Graph API in platform. EAS (ActiveSync); EWS (​Web Services); Microsoft Graph; A better way to integrate with  All EWS functionality is associated with a version of the schema. New EWS schema versions are introduced in new releases of Exchange Server or Exchange Online. The RequestServerVersion element contains a Version attribute that maps the server version to the schema version.

The Developer's Guide to the Microsoft Exchange APIs (EAS, EWS , According to Microsoft "Exchange Web Services (EWS) provides the functionality to by Bethany Sanders and Ning Xie How to Use Exchange Web Service in C++ With gSOAP. Below you will find the project build instructions with links to the files you can Next we need to set the SOAP Header to the EWS 2010 version:. The binary MAPI protocol is proprietary and poorly documented. Exchange supports IMAP and POP, but these protocols only give acesss to emails, not the calendar, address book, todo lists etc. But beginning with version 2007, Exchange now ships with a SOAP interface called Exchange Web Services, or EWS.

gSOAP EWS Example, Exchange Web Services (EWS), an alternative to the MAPI protocol, is a documented SOAP-based protocol introduced with Exchange Server 2007. Exchange  There are 2 methods to use to find the URL: 1. Use a PowerShell command on the Microsoft Exchange Server. Open the Exchange Management Shell on the Exchange server; Type Get-WebServicesVirtualDirectory |Select name, *url* | fl; The URL will be displayed; 2. Use Microsoft Outlook (2007 and later) that connects to the same Exchange EWS Connector. Hold the Ctrl key and right click on the Outlook Icon in the system tray; Select “Test E-mail Auto Configuration” from the menu; Type in an email

Comments
  • Thanks for your answer. Trying to find lowest/oldest version for both OnPrem and Cloud-based server I need support now.
  • Exchange 2007_SP1 should be lowest version you will come across but the number of 2007 installs are fast declining because of supportability.