I am trying to connect to the on-premise exchange server (2007 SP1) using EWS 2.0 Java api ([ews-java-api][1]).
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.setTraceEnabled(true);
service.setTraceFlags(EnumSet.allOf(TraceFlags.class));
service.setTraceListener(new ITraceListener() {
public void trace(String traceType, String traceMessage) {
System.out.println("Type:" + traceType + " Message:" + traceMessage);
}
});
service.setCredentials(new WebCredentials("user", "password"));
service.autodiscoverUrl("username@resmed.com.au", new RedirectionUrlCallback() );
However, the autodiscovery is failing. Similar code written in .Net using managed API is working though. The Trace information looks like following.
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:43Z">
Trying to call Autodiscover for username@resmed.com.au on https://resmed.com.au/autodiscover/autodiscover.xml.
</Trace>
Type:AutodiscoverRequestHttpHeaders Message:<Trace Tag="AutodiscoverRequestHttpHeaders" Tid="1" Time="2016-02-19 14:00:43Z">
POST /autodiscover/autodiscover.xml HTTP/1.1
Content-type : text/xml; charset=utf-8
Keep-Alive : 300
User-Agent : ExchangeServicesClient/0.0.0.0
Connection : Keep-Alive
Accept : text/xml
</Trace>
Type:AutodiscoverRequest Message:<Trace Tag="AutodiscoverRequest" Tid="1" Time="2016-02-19 14:00:44Z">
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>username@resmed.com.au</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:44Z">
null failed: I/O error: Host name 'resmed.com.au' does not match the certificate subject provided by the peer (CN=connect.resmed.com, OU=Information Technology, O=ResMed Inc., L=Bella Vista, ST=NSW, C=AU)
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:44Z">
Trying to call Autodiscover for username@resmed.com.au on https://autodiscover.resmed.com.au/autodiscover/autodiscover.xml.
</Trace>
Type:AutodiscoverRequestHttpHeaders Message:<Trace Tag="AutodiscoverRequestHttpHeaders" Tid="1" Time="2016-02-19 14:00:44Z">
POST /autodiscover/autodiscover.xml HTTP/1.1
Content-type : text/xml; charset=utf-8
Keep-Alive : 300
User-Agent : ExchangeServicesClient/0.0.0.0
Connection : Keep-Alive
Accept : text/xml
</Trace>
Type:AutodiscoverRequest Message:<Trace Tag="AutodiscoverRequest" Tid="1" Time="2016-02-19 14:00:44Z">
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>username@resmed.com.au</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:44Z">
null failed: I/O error: autodiscover.resmed.com.au
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:44Z">
Trying to get Autodiscover redirection URL from http://autodiscover.resmed.com.au/autodiscover/autodiscover.xml.
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:44Z">
No Autodiscover redirection URL was returned.
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:44Z">
Trying to get Autodiscover host from DNS SRV record for resmed.com.au.
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:45Z">
DnsQuery returned error 'DNS name not found [response code 3]'.
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:45Z">
No appropriate SRV record was found.
</Trace>
Type:AutodiscoverConfiguration Message:<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2016-02-19 14:00:45Z">
No matching Autodiscover DNS SRV records were found.
</Trace>
The Autodiscover service couldn't be located.