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

16th
Nov 2018
Pavel Kropachev
@pkropachev
Nov 16 2018 05:56

@medhanafi
You can join declaration and assignment for 'inbox' variable.
Use:

Folder inbox = Folder.bind(this.service, WellKnownFolderName.Inbox);

Instead of:

Folder inbox = new Folder(this.service);
inbox = Folder.bind(this.service, WellKnownFolderName.Inbox);

Your code works in my case, I use Office 365.

EwsRequest:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Header>
        <t:RequestServerVersion Version="Exchange2010_SP2"/>
    </soap:Header>
    <soap:Body>
        <m:GetFolder>
            <m:FolderShape>
                <t:BaseShape>AllProperties</t:BaseShape>
            </m:FolderShape>
            <m:FolderIds>
                <t:DistinguishedFolderId Id="inbox"/>
            </m:FolderIds>
        </m:GetFolder>
    </soap:Body>
</soap:Envelope>

And EwsResponse:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorBuildNumber="1294" MajorVersion="15" MinorBuildNumber="46" MinorVersion="20" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    </s:Header>
    <s:Body>
        <m:GetFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <m:ResponseMessages>
                <m:GetFolderResponseMessage ResponseClass="Success">
                    <m:ResponseCode>NoError</m:ResponseCode>
                    <m:Folders>
                        <t:Folder>
                            <t:FolderId ChangeKey="AQAAABYAAABomMeTjbKLT4eZwT5LFu4VAAB18/r8" Id="AQMkADk1ZWNmODVkLWE0YmMtNGQ1Ni1hYzQ3LWYxZmFlMmFhADQ1NzYALgAAA+DspbZlAwZNth3fVoDGeR8BAGiYx5ONsotPh5nBPksW7hUAAAIBDAAAAA=="/>
                            <t:ParentFolderId ChangeKey="AQAAAA==" Id="AQMkADk1ZWNmODVkLWE0YmMtNGQ1Ni1hYzQ3LWYxZmFlMmFhADQ1NzYALgAAA+DspbZlAwZNth3fVoDGeR8BAGiYx5ONsotPh5nBPksW7hUAAAIBCAAAAA=="/>
                            <t:FolderClass>IPF.Note</t:FolderClass>
                            <t:DisplayName>Inbox</t:DisplayName>
                            <t:TotalCount>2</t:TotalCount>
                            <t:ChildFolderCount>0</t:ChildFolderCount>
                            <t:EffectiveRights>
                                <t:CreateAssociated>true</t:CreateAssociated>
                                <t:CreateContents>true</t:CreateContents>
                                <t:CreateHierarchy>true</t:CreateHierarchy>
                                <t:Delete>true</t:Delete>
                                <t:Modify>true</t:Modify>
                                <t:Read>true</t:Read>
                                <t:ViewPrivateItems>true</t:ViewPrivateItems>
                            </t:EffectiveRights>
                            <t:UnreadCount>1</t:UnreadCount>
                        </t:Folder>
                    </m:Folders>
                </m:GetFolderResponseMessage>
            </m:ResponseMessages>
        </m:GetFolderResponse>
    </s:Body>
</s:Envelope>
Do you use on-premise Exchange server? Could you capture raw SOAP?
Just add the following code before use the ExchangeService:
            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);
                }
            });