Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Autodiscover fails if POST /autodiscover/autodiscover.xml is used instead of GET /autodiscover/autodiscover.xml #452

Open
@mbialkowskigmc

Description

@mbialkowskigmc

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">&#xd; Host returned enabled endpoint flags: [Legacy]&#xd; </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">&#xd; Host returned enabled endpoint flags: [Legacy, Soap, WsSecurity]&#xd; </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());

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions