First Look to EWS

Since 1998 the first contact I got with Microsoft Exchange and Unified Messaging I know Frank Carius Website and it was the prefered second place after the MSDN or Microsoft Knowledge and MS Support  Site  to look at and to start looking for getting news and hints for some Exchange problems. Also I got good hints or deeper information when I started in developing smal Workflowsolutions for Outlook and Exchange 5.5.

So till now I can advise anyone how is interested into Exchange to start with look here. Also for the Exchange Web Services:


http://www.msxfaq.de/code/ews.htm

Exchange Developement

http://social.technet.microsoft.com/Forums/en/exchangesvrdevelopment/threads

Exchange WEBSERVICES SOAP

 

http://archive.msdn.microsoft.com/ewsjavaapi    :

 

 

User authentication seems to be ok... web service methods calls throw the exception above... whats wrong? any suggestions? thx

 

nestoru wrote  Mar 3 2011 at 6:41 PM 

Hi,

Here are some suggestions:

1. Opening an official project with bug tracking etc. This is the second file that I see with the same version number. Version tracking is important.
2. Fixing the ant script so it actually works. People can then generate a jar file and then later include it in their projects no matter if they use Eclipse, Netbeans etc.
3. Mavenizing the project should be the best to do in my opinion. That will keep installation instructions straightforward and seamless integration in existing projects === more agile.

For those looking for a free open source alternative (and already tested Java API) you can checkout the code based on JAX-WS from http://nestorurquiza.googlecode.com/svn/trunk/ews/ A discussion about the EWS SOAP API including the history about why I picked JAX-WS can be reached at http://thinkinginsoftware.blogspot.com/2011/02/exchange-web-services-ews-from-java.html

Thanks for the work on this managed API
-Nestor


http://thinkinginsoftware.blogspot.de/2011/02/exchange-web-services-ews-from-java.html

 

http://jax-ws.java.net/2.2.1/

 

 

https://github.com/haschibaschi/java-microsoft-exchange-webservice-access

 

 

EWS Tracing

 

Example to enable Tracing EWS:

 

                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
                //enable tracing
                ITraceListener myTracer = null;
                //myTracer.trace(arg0, arg1);
                service.setTraceListener(myTracer);
                service.setTraceEnabled(bTraceit); //TRACE ACTIVIEREN   

 

If no flags are set all flags will be traced!

 

Useful hints can be found also here:

 

http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.autodiscover.autodiscoverservice.getusersettings%28v=exchg.80%29

 

https://github.com/scottbessler/ewsjavaapi

http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.autodiscover.autodiscoverservice.getusersettings%28v=exchg.80%29

 

http://archive.msdn.microsoft.com/ewsjavaapi

 

Example CLASS to use Trace with XML in JAVA

 

//

//  Converted code from C# to JAVA

//  Code written by NNellen 2013/2014

//

 

import java.io.ByteArrayInputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import microsoft.exchange.webservices.data.ITraceListener;

import org.w3c.dom.Document;


public class MyTraceListener implements ITraceListener {
 
   
    public void trace(String traceType, String traceMessage)
    {
        CreateXMLTextFile(traceType, traceMessage.toString());
    }
   
   
   
    private void CreateXMLTextFile(String fileName, String traceContent)
    {
       
        // Create a new XML file for the trace information.
   
        try{
           
            Document xmlDoc  = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().newDocument();
            xmlDoc=loadXMLFromString(traceContent);
           
            //Element myRootElement = xmlDoc.createElement("myroot");
           
            TransformerFactory.newInstance().newTransformer().transform(
                    new DOMSource(xmlDoc), new StreamResult(fileName + ".xml"));
        }
        catch (Exception e)
        {
            OwnLib myLib= new OwnLib();
            // If the trace data is not valid XML, save it as a text document.
            myLib.debuglog(fileName + ".txt", traceContent);
        }
    }
   
    public Document loadXMLFromString(String xml) throws Exception
    {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

        factory.setNamespaceAware(true);
        DocumentBuilder builder = factory.newDocumentBuilder();

        return builder.parse(new ByteArrayInputStream(xml.getBytes()));
    }


}