Part I: Java -> MS Exchange Server

To assist my laziness I tried to write a utility that helps me check the available meeting rooms for booking faster than having to go to Outlook’s Calendar’s Scheduling Assistant.

Luckily, I found that my mail server has enabled Web Services, which should make my job much easier. The WSDL can be found at “”. I tried to use Axis to generate the stubs, but hit an error.

ReminderMinutesBeforeStartType>null already exists

I searched and couldn’t find anything. Not wanting to dig into the implementation, I tried to switched to JAXWS. Not going well either.

At least one WSDL with at least one service definition needs to 
be provided.

This time I found the answer here. In fact I hit all the same problems as described even after solving this. I’ll repeat the solution here because I realize linking is good, but the sites might get torn down after some time.

Download the Services.wsdl, messages.xsd and types.xsd to your local disk. Edit Services.wsdl to add the service definition manually.


With this added I generated the stubs. I used the “-Xnocompile” option to keep the .java files, so I copied them into Eclipse directly. This will be needed as we need to hack the source later.

I tried to call a simple API first – to resolve a name, or “Check Names”. How do I know what to call? Read the documentation.

ExchangeServices factory = new ExchangeServices();
ExchangeServicePortType service = factory.getExchangeServicePort();

// prepare request		
ResolveNamesType request = new ResolveNamesType();

// prepare response
Holder responseHolder = 
    new Holder();

service.resolveNames(request, responseHolder);

ResolveNamesResponseMessageType response = 
    (ResolveNamesResponseMessageType) responseHolder.value.getResponseMessages()
for (ResolutionType resolution: response.getResolutionSet().getResolution()) {
  System.out.printf("%s: %s", resolution.getMailbox().getName(), 

I hit the isNil problem also as described in the guide, so just comment out the fields that you are not using in ExchangeServicePortType such that you are left with the request and response.

This example is meant to demonstrate how to access Exchange with Java Web Services. If you use it you will likely need to handle errors, exceptions, nulls and the like.

Part II will show how to query the resource availability, and Part III shows how to display this results graphically using JFreeChart.

3 thoughts to “Part I: Java -> MS Exchange Server”

  1. Hi,
    Very good information presented. It is very useful who ever wants to invoke MSExchange services.

    from last 3 days I was finding to get the WSDL for the MSExchange webservices.
    I read the link
    and found some webservices availability.

    In this blog some lines of text is not wraped and we could see the complete line.
    if you can make it visible then it would be great.

    Thanks and Regards,

  2. I need to add a functionality of creating meeting requests through java on a portlet.
    So I need your help. Please can you provide your contact details.

    Thanks you.

  3. I finally had that bit of time to make my code scrollable for anyone’s viewing pleasure (at least in FF10, IE9 and CR17).

    As a future tip for other sites that have this problem but the author is too lazy to fix it, you can either:
    1. Do a select on the affected lines and do a copy/paste into Notepad.
    2. View Source

Leave a Reply