EWS Java API 1.2 – get started!


August 28th, 2014 update:
The EWS Java API is now available on GitHub as an open source project, ews-java-api. For more details, see the new blog post on http://blogs.office.com/dev

__________________________________ 

The EWS Java API 1.2 is now available, with added support for functionality in Exchange Server 2010 SP2. It also includes an important update to the license terms that affects what you can do with the source code and the redistribution terms.

Feature-wise, we’ve implemented the following updates to the EWS Java API, which might be of interest to you:

  • The API now targets the Exchange 2010 SP2 version of the schema.
  • We’ve added synchronous request-response pattern implemented for handling communication with the service.
  • The FullContactData option of the ResolveNames operation now includes new directory properties.
  • Streaming notifications includes the following updates :
    • Subscription creation no longer causes a deadlock.
    • The StreamingSubscription object no longer causes a crash when the Microsoft.Exchange.Data.Storage.MailboxSession object is disposed.
  • Get password expiration date functionality has been implemented.
  • Logging capability for the HTTP headers is now included.
  • The HTTPHeader collection now correctly populates with the response HTTP headers.

For more information about what’s new in the EWS Java API 1.2, see the release notes included in the download.

In some ways, the biggest change is that we have updated the license terms to give you a bit more freedom to customize the EWS Java API. The license updates enable you, the licensee, to do the following:

  1. Modify the source code to fix bugs and make improvements in your own private branch of the code.
  2. Redistribute in binary format only, as part of your application, the EWS Java API, with any changes that you have made to the original source code.
  3. Submit bug fixes or source code to Microsoft. We can incorporate the fixes into future API releases, at our discretion.

As always, be sure to review the authoritative license terms for details.

Hopefully, these more flexible terms will open more possibilities for you to incorporate Exchange integration into your products. This update has been a long time coming, so start up your IDE, rev up your (private) code repository, and take off using the latest EWS Java API!


Comments (26)

  1. EWS_user says:

    Thank you, Mike for this note.

    Any plan to support 2013 version?

  2. Michael.Mainer says:

    Hello EWS_user,

    I sure hope there are plans to support 2013 and later. You've got my vote on further development of the EWS Java API (and license terms). I'm not aware of the current plans for additional development of the EWS Java API. I will pass along your interest in seeing 2013 support.

    With regards,

    Michael Mainer

    Microsoft Corporation

  3. Hi,

    Thanks for the new API and the post.

    I found that there option to impersonate user using EWS API.

    Is there any way to use impersonation accessing exchange via IMAP ? or the impersonation is works only the EWS API.

    Thanks.

  4. Stefan says:

    Thanks for the API!

    I new thats not the write place to put questions but I simply found no other:

    I'm havin a problem downloading huge attachments on systemy with limited memory, since everything is loaded into memory first – even if I use IFileAttachmentHandler oder load(stream). Is there a posibility to direclty stream the attachment or the whole item to an outputstream without downloading everything to memory first?

    big thanks!

  5. Stefan says:

    I just patched it for attachment and mime-content streaming – if someone is interested send me an mail to selbitschka [at] gmail [dot] com. I also would submit it as patch if someone tells me where.

  6. Michael.Mainer says:

    Hello Stefan,

    Any bugs or proposed updates to the offical API can be submitted to ewsjavaapi@sqlserver.org. Include a problem definition, the fix description, and the modified source files.

    With regards,

    Michael Mainer

    Microsoft Corporation

  7. Martin Strube says:

    Hi Michael

    Thanks so far. How do I get a calendar that does not belong to my own account? Meaning that I want to know the Appointments of a "meeting room" within a timeframe. I guess the "meeting room" is a normal user that has a calendar. But I don't know how to connect to it.

    Thanks

    Martin

  8. Charlie Huggard says:

    Hi Michael. I was wondering 2 things…

    1) Could the code be hosted on Github, Bitbucket, or something similar to make it easier for people to make forks, share patches with each other and submit pull requests publicly back to Microsoft? submitting a patch via email seems almost like a black hole, but people could test and comment on eachother's patches and comment on code if managed in such a way.

    2) Are there plans to submit official artifacts to Maven Central or for Microsoft to host a Maven repository to make it easier for people to just pull the base EWS Java API into their projects? (Forks of course would have to maintain their own repositories or distribution channels)

    Regards,

    Charlie

  9. Levent says:

    Our client is using ExchangeVersion.Exchange2007_SP1 whereas Rockspace is using ExchangeVersion.Exchange2010 But when I use the credentials(username, password and url) that our client provided, I am getting this error:

    Apr 05, 2013 1:49:13 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme

    INFO: Basic authentication scheme selected

    Apr 05, 2013 1:49:13 PM org.apache.commons.httpclient.HttpMethodDirector processAuthenticationResponse

    SEVERE: Invalid challenge: Basic

    org.apache.commons.httpclient.auth.MalformedChallengeException: Invalid challenge: Basic

    at org.apache.commons.httpclient.auth.AuthChallengeParser.extractParams(AuthChallengeParser.java:98)

    at org.apache.commons.httpclient.auth.RFC2617Scheme.processChallenge(RFC2617Scheme.java:94)

    at …

    I couldn't find any solution for this issue. Please provide any info that you think I can get authenticated for EWS.

    I know the credentials that our client provided works because I can log in by using them on web interface.

    Thanks

  10. Hello Levent,

    what auth mode was configured for EWS Website in IIS?

    Try basic with SSL or digest

    Apache Commons HttpClient 3.1 (commons-httpclient-3.1.jar)does not implement NTLMv2, it only implements the older NTLM (aka NTLMv1)

  11. Creating an Appointment says:

    I can't create an appointment with the API, because I can't create a TimeZoneDefinition properly, no matter what I do.  By the way, the documentation doesn't even address needing to add a "startTimeZone" to an appointment.

  12. How to create an appointment using TimeZoneDefinition? says:

    I am not able to create an appointment using TimeZoneDefition on Exchange 2007. I always get "The time zone definition is invalid or unsupported."

    What is the correct syntax?

  13. Mickael says:

    Hi Michael

    Is it possible to use this version against Exchange 2013 (if one doesn't need any new 2013 specific functionality?)

    Regards

    Mickael

  14. Subhrodeep Mukherjee says:

    Hi Michael,

    Do we have support for Exchange 2013?

    Regards,

    Subhrodeep Mukherjee

  15. Chris says:

    Hi Michael

    How do I use getConflictingMeetingCount?

    I'll getting Exception:

    This operation can't be performed because this service object doesn't have an Id.

  16. Mimi Gentz says:

    Just an update that the EWS Java API is no longer available on archive.msdn.microsoft.com/ewsjavaapi. It's being moved to code.msdn.microsoft.com/Exchange-EWS-Java-API-12-1a5a1143 and will be available soon.

  17. Roberto says:

    Hi All,

    there's an error into EwsXmlReader.

    It's Ok when running into standalone app, but not when it's run into weblogic server.

    A workaround is :

    – Method isStartElement :

    public boolean isStartElement(XmlNamespace xmlNamespace, String localName) {

    return (this.isStartElement())

    && (this.getLocalName().equals(localName))

    && ((this.getNamespacePrefix().equalsIgnoreCase(EwsUtilities.getNamespacePrefix(xmlNamespace)))

    || (this.getNamespaceUri().equalsIgnoreCase(EwsUtilities.getNamespaceUri(xmlNamespace))));

    }

    – Method internalReadElement:

    private void internalReadElement(XmlNamespace xmlNamespace,

    String localName, XMLNodeType nodeType) throws Exception {

    if (xmlNamespace == XmlNamespace.NotSpecified) {

    this.internalReadElement("", localName, nodeType);

    } else {

    this.read(nodeType);

    if ((!this.getLocalName().equals(localName)) ||

    (!this.getNamespaceUri().equalsIgnoreCase(EwsUtilities.getNamespaceUri(xmlNamespace)))) {

    throw new ServiceXmlDeserializationException(

    String

    .format(

    Strings.UnexpectedElement,

    EwsUtilities

    .getNamespacePrefix(

    xmlNamespace),

    localName, nodeType.toString(), this

    .getName(), this.getNodeType()

    .toString()));

    }

    }

    }

  18. Someone's Dev Account says:

    I noticed that EWS Java 1.2 has been marked with an Apache 2.0 license. Let me just say this…

    FINALLY!

    If ever there was a project that needed it, it's EWS Java. That API has seemingly turned into abandonware and the old license forbade redistribution of modified source, so the many bugs in it had to be independently fixed by devs around the world. Not fun. With a proper open source license, this problem can be alleviated.

    HOWEVER…

    After downloading the zip file from the new EWS Java page, I've found that while the Apache 2.0 license is present in the root directory, the earlier and more restrictive license is still present in the project directory. This introduces ambiguity into the license terms. Not good. I would not be comfortable redistributing modified (or even original) source code with this kind of ambiguity, even if it's just an oversight on Microsoft's part. Please remove the old license entirely from the API.

    Also, if possible, can this get an official repository? The new license is great, but with only a zip file as an "official" source, it's begging for fragmentation across who-knows-how-many repositories and accounts, especially since it's not even a proper Maven project.

    I'd love to do some work on EWS Java myself (I've already fixed a number of bugs), but with the license issues and lack of an official repository, that doesn't seem terribly feasible.

  19. Mimi Gentz says:

    I responded to "Someone's Dev Account" via email, but I'll post here as well.

    In response to your licensing questions, we removed the Apache license from the download package. The original license still applies. With that said, in what way do you find the original license restrictive, as it does allow you to modify and redistribute the source code with applications you develop? If you could share your concerns, maybe we can clarify or address them – or at least pass them along.

    As for an official repository, your point is well taken and I’ve passed it on to the code owners.

  20. Shekhar says:

    hello guys …

    i have created a account on outlook.com

    and now I am trying to read the Inbox as shown below.

    But it is not working for me.

    My code gets stuck at the line: service.autodiscoverUrl(EMAIL_ID);

    Can someone point me to the solution.

    Is this EWS suppose to work with Outlook.com?

    ———————————————————————————————————-

    ExchangeService service = new ExchangeService();

    ExchangeCredentials credentials = new WebCredentials(EMAIL_ID, EMAIL_PWD);

    service.setCredentials(credentials);

    try {

    System.out.println("111111111111111");

    service.autodiscoverUrl(EMAIL_ID);

    System.out.println("222222222222222");

    ItemView view = new ItemView(10);

    FindItemsResults<Item> findResults;

    findResults = service.findItems(WellKnownFolderName.Inbox, view);

    for(Item item : findResults.getItems())

    {

    item.load();

    System.out.println(item.getSubject());

    }

    } catch (Exception e) {

    e.printStackTrace();

    }

  21. vb1980 says:

    i m also facing the same issue as posted by Shekhar.

    any solution to this.

    i also see below in the Console ..

    Jun 05, 2014 7:46:29 PM org.apache.commons.httpclient.HttpMethodBase readResponseBody

    INFO: Response content length is not known

    Jun 05, 2014 7:46:29 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme

    INFO: Basic authentication scheme selected

    Jun 05, 2014 7:46:34 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry

    INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect

    Jun 05, 2014 7:46:34 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry

    INFO: Retrying request

    Jun 05, 2014 7:46:35 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry

    INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect

    Jun 05, 2014 7:46:35 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry

    INFO: Retrying request

    Jun 05, 2014 7:46:37 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry

    INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect

    Jun 05, 2014 7:46:37 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry

    INFO: Retrying request

    Jun 05, 2014 7:46:40 PM org.apache.commons.httpclient.HttpMethodBase readResponseBody

    INFO: Response content length is not known

    Jun 05, 2014 7:46:41 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme

    INFO: Basic authentication scheme selected

    Jun 05, 2014 7:46:43 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme

    INFO: Basic authentication scheme selected

    Jun 05, 2014 7:46:45 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme

    INFO: Basic authentication scheme selected

    Jun 05, 2014 7:46:45 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme

    INFO: Basic authentication scheme selected

  22. Stefan Uebe says:

    Hi,

    the EWS Managed API is currently at version 2.0. Can anyone tell me if the difference to "our" 1.2 is large or if there are any plans for upgrading the Java API to 2.0, too?

    Thanks and regards,

    Stefan

  23. Aj says:

    Hi,

    I have one doubt, with 1.2 is there any way we can send EmailMessages as a list. My ultimate goal is to collect all the EmailMessage as a list and send to avoid multiple calls.

  24. mjb says:

    Mimi: you wrote:

    "I responded to "Someone's Dev Account" via email, but I'll post here as well.

    In response to your licensing questions, we removed the Apache license from the download package. The original license still applies. With that said, in what way do you find the original license restrictive, as it does allow you to modify and redistribute the source code with applications you develop? If you could share your concerns, maybe we can clarify or address them – or at least pass them along.

    As for an official repository, your point is well taken and I’ve passed it on to the code owners."

    ============

    The concerns are simple.

    1. MS's updates have been rare, and there are strong signs of this being abandonware. As it is many 2013 new things are not exposed.

    2. Hence sending bug fixes, patches, and improvements to MS doesn't seem to help, since no one else will ever know about them.

    3. There are many members of the community who would like to fix the code, enhance it, etc. We don't need to brand it as MS approved, but we need the legal right to post on github modified code and collaborate.

    Please please please consider a license modification!

  25. Mimi Gentz says:

    August 28th, 2014 update:

    The EWS Java API is now available on GitHub as an open source project, ews-java-api. For more details, see the new blog post (blogs.office.com/…/open-sourcing-exchange-web-services-ews-java-api) on http://blogs.office.com/dev.

    Github project: github.com/…/ews-java-api

    Blog post: blogs.office.com/…/open-sourcing-exchange-web-services-ews-java-api

  26. mjb says:

    Thank you mime et al!