none
EWS Java API Call Back Help with the autoDiscoverURL Method RRS feed

  • Question

  • Hello Everyone,

    Sorry for the redundant post. First let me say that the Java API is very valuable and I appreciate it dearly. But (here it comes), I cannot be the only person that is having a hard time in getting Autodiscovery to work correctly :) I just don't know enough about callbacks in other languages to build a workaround for what is needed in Java, and in all honesty, the "Getting Started Guide..." that comes with the Java API looks like it references C# on a few occasions and was not converted to Java.

    I am trying to figure out how I can call the service.autoDiscoverURL(email, AutodiscoverRedirectionUrlValidationCallback); and expect the java compiler to know that this is supposed to call a static method in the class. I'm flying blindly here.

    My understanding is that we are in fact calling the autodiscoverRedirectionUrlValidationCallback Method on the IAutodiscoverRedirectionUrl interface. Or, more likely, we are supposed to be passing the returned URL from the DNS server to the instance of AutodiscoverService and it's autodiscoverRedirectionUrlValidationCallback Method as the instance implements the interface. Wouldn't I need to reference that instance somehow? I would normally do this through an anonymous class, but I am new to the API and completely lost. Any help would be greatly appreciated!

    Thanks again and happy new year!

    Matt B

    Friday, December 30, 2011 1:50 AM

Answers

  • OK! Well I feel like a goof. Talk about tunnel vision! I scoured the Internet and couldn't find anything. Then, I realized that I was orignially thinking that we normally would create an anonymous class to handle this. But I needed to implement the interface, 2 and 2 came together, and here we are.

    I had to create a class that implemented the IAutodiscoverRedirectionURL and overrides the autodiscoverRedirectionUrlValidationCallback method.

     

    package com.-----;
    /**
     * ------
     * @author Matthew Bram
     * Copyright (c) 2011 --------------
     * All Rights Reserved.
     * @version 1.1
     */
    import microsoft.exchange.webservices.data.AutodiscoverLocalException;
    import microsoft.exchange.webservices.data.IAutodiscoverRedirectionUrl;

    public class URLCallBack implements IAutodiscoverRedirectionUrl {

        @Override
        public boolean autodiscoverRedirectionUrlValidationCallback(String arg0)
                throws AutodiscoverLocalException {

            // Do your evaluation here
            return true;
        }

    }

     

    Then, instantiate the new Object in the class that you are creating the service on. Pass this object to the autodiscoverURL method of the service. Just make sure you catch any exceptions thrown on the input side.

     

    Cheers and Happy New Years!

    • Marked as answer by Matt Bram Friday, December 30, 2011 11:52 PM
    Friday, December 30, 2011 5:26 AM