Get service configuration information by using EWS in Exchange

Find out how to get service configuration information for UM, policy nudges, mail tips, and protection rules from EWS in Exchange.

Does your EWS application work with Unified Messaging (UM), policy nudges, mail tips, or protection rules? If so, your application will need to call the GetServiceConfiguration operation to get the service configuration information that it needs. The GetServiceConfiguration operation returns configuration information that is specific to each of these EWS features.

Note

The EWS Managed API does not implement this functionality.

Table 1. Configuration information that the GetServiceConfiguration operation returns

EWS feature GetServiceConfiguration operation returns…
UM
  • A value that indicates whether UM is enabled.
  • A value that indicates whether play on phone is enabled.
  • The play on phone dial string.
Policy nudges
  • Policy nudges for display in your client.
Mail tips
  • A value that indicates whether mail tips are enabled.
  • The maximum number of recipients per request.
  • The maximum message size.
  • The large audience threshold.
  • A value that indicates whether the number of external recipients is shown.
  • A list of internal domains.
  • A value that indicates whether policy tips are enabled.
  • The large audience cap threshold for indicating whether your mail is considered to have a large number of recipients.
Protection rules
  • Protection rules setup for your client.
  • A list of domains that are internal to your organization.

Code example: Get service configuration information for mail tips by using EWS

The following code example uses the GetServiceConfiguration operation to request service configuration information for mail tips. You can request additional service configuration information by adding more ConfigurationName elements with different values.

private static void GetServiceConfiguration(ExchangeService service, NetworkCredential creds)
{ 
  // XML for the GetServiceConfiguration request SOAP envelope for mail tips configuration information.
  const string getServiceConfigurationRequest = 
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
    "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
    "               xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\"\n" +
    "               xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" \n" +
    "               xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
    "               xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
    "  <soap:Header>\n" +
    "    <t:RequestServerVersion Version=\"Exchange2013\" />\n" +
    "  </soap:Header>\n" +
    "  <soap:Body>\n" +
    "    <m:GetServiceConfiguration>\n" +
    "      <m:ActingAs>\n" +
    "        <t:EmailAddress>user1@contoso.com</t:EmailAddress>\n" +
    "        <t:RoutingType>SMTP</t:RoutingType>\n" +
    "      </m:ActingAs>\n" +
    "      <m:RequestedConfiguration>\n" +
    "        <m:ConfigurationName>MailTips</m:ConfigurationName>\n" +
    "      </m:RequestedConfiguration>\n" +
    "    </m:GetServiceConfiguration>\n" +
    "  </soap:Body>\n" +
    "</soap:Envelope>";
  // Encoded GetServiceConfiguration operation request.
  byte[] payload = System.Text.Encoding.UTF8.GetBytes(getServiceConfigurationRequest);
  try
  {
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(service.Url);
    request.AllowAutoRedirect = false;
    request.Credentials = creds;
    request.Method = "POST";
    request.ContentType = "text/xml";
    Stream requestStream = request.GetRequestStream();
    requestStream.Write(payload, 0, payload.Length);
    requestStream.Close();
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    if (response.StatusCode == HttpStatusCode.OK)
    {
      Stream responseStream = response.GetResponseStream();
      StreamReader reader = new StreamReader(responseStream);
      string responseFromServer = reader.ReadToEnd();
      Console.WriteLine("You will need to parse this response to get the configuration information:\n\n" + responseFromServer);
      reader.Close();
      responseStream.Close();
    }
    else
      throw new WebException(response.StatusDescription);
          
  }
  catch (WebException e)
  {
    Console.WriteLine(e.Message);
  }
}

Next steps

After you request service configuration information, use the XmlDocument class to load the response XML so that you can parse it. Then, depending on your scenario, you can do one of the following:

See also