-
Notifications
You must be signed in to change notification settings - Fork 560
Autodiscover fails if POST /autodiscover/autodiscover.xml is used instead of GET /autodiscover/autodiscover.xml #452
Comments
Do you have a code sample of what you were using to test the AutoDiscover service? |
I dont have isolated test code, only app. code, relevant fragments are:
|
the "fix" I made was
|
Interesting. I'm using a different method to look up the URL. Here is my code:
When I tried a variation of your code here, it resulted in the same error you got. |
We are also running into this issue with Office365 accounts. |
I've managed to reproduce this as well and also confirmed that mbialkowskigmc's fix works correct. From the code it definitely appears that the intended request is GET but this is overridden by the default POST request which does not result in the X-SOAP-Enabled being set in the response. This causes AutodiscoverService to fallback to the legacy endpoint which also slows down the autodiscover process noticeably. I'm not familiar enough with the whole autodiscover process (seems like black magic to me and not well documented) but it definitely seems like a GET request was intended, and this is what the C# managed api seems to be doing a well. I can submit a pull request. |
I have same issue.
I have same code which avromf had post.
But it does not work :(
|
Hello, Could you show piece of your code? And what is Java version you use? |
Hi pkropachev. I think I fixed my problem. Thanks! |
Hello @dan-oneil ! |
I realized the credentials were being set after the call was made. I made the call after setting credentials in the class that extended ExchangeServer and all is well! Thanks :-) |
Hi,
I have client application using cloud based Office 365. After upgrade to the ews-java-api 2.0 from previously used Microsoft's EWSJavaAPI 1.2 library, autodiscover stopped working correctly.
After analysing logs I found that in the autodiscover process the previous EWS library was making a GET request to autodiscover service :
2015-11-04 06:39:02.066-08 | FINE | Startup-1_31_6 | org.apache.commons.httpclient.Wire | wire | >> "GET /autodiscover/autodiscover.xml HTTP/1.1[\r][\n]" 2015-11-04 06:39:02.144-08 | FINE | Startup-1_31_6 | org.apache.commons.httpclient.Wire | wire | << "HTTP/1.1 200 OK[\r][\n]" 2015-11-04 06:39:02.144-08 | FINE | Startup-1_31_6 | org.apache.commons.httpclient.Wire | wire | << "X-SOAP-Enabled: True[\r][\n]" 2015-11-04 06:39:02.144-08 | FINE | Startup-1_31_6 | org.apache.commons.httpclient.Wire | wire | << "X-WSSecurity-Enabled: True[\r][\n]"
the ews-java-api 2.0 is using POST instead of GET :
2015-11-04 06:04:24.626-08 | FINE | Startup-1_30_6 | org.apache.http.wire | wire | http-outgoing-3 >> "POST /autodiscover/autodiscover.xml HTTP/1.1[\r][\n]" 2015-11-04 06:04:24.736-08 | FINE | Startup-1_30_6 | org.apache.http.wire | wire | http-outgoing-3 << "HTTP/1.1 200 OK[\r][\n]"
The response for POST to POST /autodiscover/autodiscover.xml is also HTTP 200 OK, however the response is missing the X-SOAP-Enabled: True and X-WSSecurity-Enabled: True headers.
Because of that, the ews-java-api assumes only Legacy endpoint is enabled
2015-11-04 06:04:24.782-08 | FINEST | Startup-1_30_6 | microsoft.exchange.webservices.data.misc.EwsTraceListener | trace | AutodiscoverConfiguration - <Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2015-11-04 14:04:24Z">
 Host returned enabled endpoint flags: [Legacy]
 </Trace>
and reports error:
microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException: The Autodiscover service couldn't be located.
When changed the code to use GET instead of POST in AutodiscoverService.tryGetEnabledEndpointsForHost() , things started to work correctly
<Trace Tag="AutodiscoverConfiguration" Tid="19" Time="2015-11-06 10:25:29Z">
 Host returned enabled endpoint flags: [Legacy, Soap, WsSecurity]
 </Trace>
note also that AutodiscoverService.java:1522 has
request.setRequestMethod("GET");
however HttpClientWebRequest.java:102 is always using POST request
httpPost = new HttpPost(getUrl().toString());
The text was updated successfully, but these errors were encountered: