These are chat archives for OfficeDev/ews-java-api

19th
Nov 2018
medhanafi
@medhanafi
Nov 19 2018 13:18
Hello thanks, after join declaration and assignment for 'inbox' variable and adding trace code , i got this:
Type: EwsRequestHttpHeaders
Message: <Trace Tag="EwsRequestHttpHeaders" Tid="16" Time="2018-11-19 13:15:20Z">
POST /ews/Exchange.asmx HTTP/1.1
Keep-Alive : 300
Content-type : text/xml; charset=utf-8
Accept : text/xml
User-Agent : ExchangeServicesClient/0.0.0.0
Connection : Keep-Alive
Accept-Encoding : gzip,deflate


</Trace>

Type: EwsRequest
Message: <Trace Tag="EwsRequest" Tid="16" Time="2018-11-19 13:15:20Z">
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><soap:Header><t:RequestServerVersion Version="Exchange2010_SP2"></t:RequestServerVersion></soap:Header><soap:Body><m:GetFolder><m:FolderShape><t:BaseShape>AllProperties</t:BaseShape></m:FolderShape><m:FolderIds><t:DistinguishedFolderId Id="inbox"></t:DistinguishedFolderId></m:FolderIds></m:GetFolder></soap:Body></soap:Envelope>
</Trace>

13:15:21.153 [http-nio-8080-exec-1] WARN  c.o.s.e.a.s.EwsService - Error occured 
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. Certificate for <domaine.com> doesn't match any of the subject alternative names: [webmail.xxxxx.com, mail.xxxxx.com, autodiscover.xxxxx.com]
    at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
and my test service
public String testService() {
        try {
            ExchangeCredentials credentials = new WebCredentials("*********@***********.com", "********!");
            credentials.preAuthenticate();
            this.service.setCredentials(credentials);
            this.service.setUrl(new URI("https://********************.com/ews/Exchange.asmx"));
            this.service.setTraceEnabled(true);
            this.service.setTraceFlags(EnumSet.allOf(TraceFlags.class));
            this.service.setTraceListener(new ITraceListener() {
                public void trace(String type, String message) {
                    System.out.println("Type: " + type + "\nMessage: " + message);
                }
            });

            Folder inbox = Folder.bind(this.service, WellKnownFolderName.Inbox);
            return new StringBuilder("INBOX (").append(inbox.getTotalCount()).append(")").toString();

        } catch (Exception e) {
            this.getLogger().warn("Error occured ", e);
        }
        return "error";
    }
Pavel Kropachev
@pkropachev
Nov 19 2018 20:51
EWS SOAP request is correct.
Looks like that hostname which you use to connect to EWS is not included to certificate of your Exchange server. In the result, verification of this hostname is failed.
You can use one of the subject alternative names from certificate to connect, e.g. "https://webmail.xxxxx.com/EWS/Exchange.asmx", "https://mail.xxxxx.com/EWS/Exchange.asmx".
Or use custom service (with non-default hostname verifier) to ignore verification of hostname (in fact, allow all hosts).
https://github.com/OfficeDev/ews-java-api/wiki/Custom-Exchange-services