Exchange Web Services (EWS) 2007 via Java

Background and Intent

These are some notes captured for later reference on how to interact with Microsoft Exchange 2007's Web Services layer with Java and raw SOAP messages. Much credit goes to Reid Miller's excellent documentation. My goal here is to summarize what I did in a concise form for later reference, provide additional link credit to Reid's documentation, and record related work for my particular use of EWS which is ultimately to shed light on the raw SOAP conversation and thereby enable access from some Mark Logic xquery servers. My hope is that this will be of help to others. If it is of use to you then help spread the knowledge by providing links to this documentation to help others along their way.

Getting the WSDL

As noted in Reid's article you must first have Exchange Web Serivices enabled. Once enabled go to https://<FQDN-of-your-echange-server>/ews/Services.wsdl. (FQDN is short for fully qualified domain name.) Save that file into a directory as exchange.wsdl. At the top of this file it contains the following code reformatted with white space for clarity. Line 5 is a relative reference to another file, messages.xsd. Follow a similar pattern in that file to arrive at the Types.xsd file as well.

1   <wsdl:types>
2     <xs:schema xmlns:xs="">
3       <xs:import 
4          namespace="" 
5          schemaLocation="messages.xsd"/>
6     </xs:schema>
7   </wsdl:types>

So the set of files that you need to save all together in the same directory and their locations relative to your exchange server are:

File Source
exchange.wsdl https://<FQDN>/ews/Services.wsdl
Messages.xsd https://<FQDN>/ews/Messages.xsd
Types.wsdl https://<FQDN>/ews/Types.xsd

As noted by Reid, modify exchange.wsdl by injecting the following code just before the closing </wsdl:definitions> tag. Warning: make sure that you replace the <FQDN> with the fully qualified domain name for your exchange server.

  <wsdl:service name="ExchangeWebService">
    <wsdl:port name="ExchangeWebPort" binding="tns:ExchangeServiceBinding">
      <soap:address location="https://<FQDN>/EWS/exchange.asmx"></soap:address>

In Types.xsd at the top of the file change the a xs:import for the XML namespace to reference to the following lines.

  <xs:import namespace="" 

Now the files are in proper format for consumption by Java's wsimport utility for generating JAX-WS classes. At the time of writing I have Java 1.6 installed:

bash-3.2$ java -version
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) Client VM (build 19.0-b09, mixed mode, sharing)

I ran the wsimport command with the following options which resulted in the following output. Run wsimport without parameters to see its options. -keep tells it to preserve the generated java files.

bash-3.2$ wsimport -keep exchange.wsdl
parsing WSDL...
generating code...
compiling code...

Once that is done I now had... TBC

This page was last modified on 13 June 2011, at 10:23.

Note: Content found in this wiki may not always reflect official Church information. See Terms of Use.