none
1.how to get all data from exchange server RRS feed

  • Question

  • Hi everybody~
    I got two problems when implementing Exchange ActiveSync(EAS) in MFC.
    because i want to implement this in mobile device, I try first in MFC application to see if I can run with the protocol or not.

    1. when I connect to google exchange (m.google.com), I can send FolderSync request with SyneKey zero and get the response which contains folder hierarchy and server id for each folder.
    After doing so, i send Sync command with the following message (convert to wbxml)
    <Sync><Collections>
        <Collection>
            <Class>Contact</Class>
            <SyncKey>0</SyncKey>
            <CollectionId>Contact:DEFAULT(this value is from the serverID that return by google server)</CollectionId>
     <GetChanges/>
     <WindowSize>100</Windows>
        </Collection>
    </Collections></Sync>
    and i get the response that contains a synckye:1

    So, I send Sync request again with
    <Sync><Collections>
        <Collection>
            <Class>Contact</Class>
            <SyncKey>1</SyncKey>
            <CollectionId>Contact:DEFAULT(this value is from the serverID that return by server)</CollectionId>
     <GetChanges/>
     <WindowSize>100</Windows>
        </Collection>
    </Collections></Sync>
    But, I get the response with only partial data.
    that is, I have total 25 contacts in my google account, but I only got 2 records of them in the wbxml which server return.
    (Of course. I don't receive the <MoreAvailable> from server)

    Can anyone tell me how to get all contact data from my google account?
    ps. I also try calendar or email, and get the same problems

    2.I try to sync with MS exchange server, but I cannot access it.
    When I send request(foldersync and sync) to exchange server, I only get the response with some HTML code which seems like a homepage that let user to enter account and password.
    Why can I not get the correct response?
    I have already includes the account and password in the http request using based64 encoding, so I think the authorization should be ok.
    And if i remove the authorization in http header, the response will be 401 error (authorization required), so I think the authorization is ok.

    But if i send http request wiht OPTIONS method,
    I can get the correct respond header that contains server version, protocol version..and so on
    This is the onle one request that i can do correctly.
    I can also sync correctly via my mobile phone. Thus, I am sure that the exchange server supports this function.
    do anyone know what the problem is?
    what is the reason that i can access Google exchange but cannot access MS Exchange server in the same way?????

    Thanks~~

    Ecroo

     

    Wednesday, April 21, 2010 2:48 PM

Answers

  • Ecroo, Thank you for the additional information. One thing jumped out at me right away that I don't think you mentioned previously, is that you are setting the MS-ASProtocolVersion to 2.5. That is not a supported version and the current version of the MS-ASCMD document is for version 14. Only version 12.1 or newer is supported.

     

    If you are sending this request to a MS Exchange 2007 server you will need to use 12.1, if it's running Exchange 2010 you will need to use 14.

     

    If you recall in my previous post I moved the Class element into the Options element. There is a note in the Appendix that this is specific to version 14. If you need to use version 12.1 you will need to remove the Options element and put the Class element back under the Collection element.


    Josh Curry (jcurry) | Sr. Support Escalation Engineer | US-CSS DSC Protocols Team
    Friday, April 23, 2010 6:19 PM
    Moderator
  • Hi Ecroo,

    As Josh pointed out on his April 23rd post, and to reiterate, we support Exchange ActiveSync (EAS) 12.1 and greater as part of the Interoperability Principles.   If you want to pursue content for EAS 2.5 you will need to contact Microsoft’s IP licensing team.  Licensing information for EAS can be found here: http://www.microsoft.com/about/legal/en/us/IntellectualProperty/IPLicensing/Programs/ExchangeActiveSyncProtocol.aspx

    If you require technical support for EAS 2.5 you will need to go through the Premier Support organization, here: http://www.microsoft.com/microsoftservices/en/us/support.aspx

    Regards,

    Mark Miller

    Escalation Engineer

    US-CSS DSC PROTOCOL TEAM


    Tuesday, April 27, 2010 9:48 PM

All replies

  • Hi, Ecroo,

      Thanks for your question.  One of our team mebmer will work on your question and post the response when investigation is done.

     

     

     


    Hongwei Sun -MSFT
    Wednesday, April 21, 2010 3:51 PM
  • Thanks~

    For more detail about my question 2:

    I try some http request in Fiddler :

    1. http method: POST, exchange command: Cmd=Sync

    POST  https://webmail.xxxxx.xxx/Microsoft-Server-ActiveSync?Cmd=Sync&User=xxxxx&DeviceId=v140Device&DeviceType=SmartPhone   HTTP/1.1

    header:

    User-Agent: Fiddler
    Host: xxx.xxx.xxx
    Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXX(account\password)
    Content-Length: 0

     

    and the response is:

    HTTP/1.1 400 Bad Request
    Connection: Keep-Alive
    Set-Cookie: XXXXXXXXXXX; HttpOnly; Domain=.xxx.com; secure; path=/
    Content-Length: 46
    Date: Thu, 22 Apr 2010 01:59:50 GMT
    Content-Type: text/html
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    MS-Server-ActiveSync: 6.5.7638.1
    Cache-Control: private

    <body><h2>HTTP/1.1 400 Bad Request</h2></body>

     

    2. http method OPTIONS

    OPTIONS https://webmail.xxx.xxx/Microsoft-Server-ActiveSync HTTP/1.1
    User-Agent: Fiddler
    Host: xxx.xxx.xxx
    Authorization: Basic XXXXXXXXXXXXXXXXXXXXX
    Content-Length: 0

    and the response is:

    HTTP/1.1 200 OK
    Connection: Keep-Alive
    Set-Cookie: xxxxxxx; HttpOnly; Domain=.xxxxx.com; secure; path=/
    Content-Length: 0
    Date: Thu, 22 Apr 2010 02:03:20 GMT
    Content-Type:
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    Public: OPTIONS, POST
    Allow: OPTIONS, POST
    MS-Server-ActiveSync: 6.5.7638.1
    MS-ASProtocolVersions: 1.0,2.0,2.1,2.5
    MS-ASProtocolCommands: Sync,SendMail,SmartForward,SmartReply,GetAttachment,GetHierarchy,CreateCollection,DeleteCollection,MoveCollection,FolderSync,FolderCreate,FolderDelete,FolderUpdate,MoveItems,GetItemEstimate,MeetingResponse,ResolveRecipients,ValidateCert,Provision,Search,Notify,Ping
    Cache-Control: private

     

    3. http method POST via http only

    POST http ://webmail.xxxxxxx.xxx/Microsoft-Server-ActiveSync?Cmd=Sync&User=xxxxx&DeviceId=v140Device&DeviceType=SmartPhone HTTP/1.1
    User-Agent: Fiddler
    Host: xxx.xxx.xxx
    Authorization: Basic xxxxxxxxx
    Content-Length: 0

    and the responses are:

    First i got a 302 redirect to Location: https ://webmail.xxxxx.xxx/exchange

    Second, I also got a 302 redirect to Location: https ://webmail.xxx.xxx/Exchange/

    Finally, I got a 200 OK, and the response body is

    <!--Copyright (c) 2000-2003 Microsoft Corporation. All rights reserved.-->
    <!--CURRENT FILE== "NON-IE5" "NON-WIN32" frameset -->
    <!--CURRENT TEMPLATE == frameset.00000000 -->
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
    <TITLE>Microsoft Outlook Web Access</TITLE>
    <BASE href="https://webmail.xxxx.xxx/Exchange/mycount/">
    </HEAD>
    <SCRIPT language="JavaScript">
    var g_iNewWindowWidth = 700;
    var g_iNewWindowHeight = 500;
    var g_fWarnOnLogOff=false;
    function WarnOnLogOff()
    {
    if (g_fWarnOnLogOff)
    alert("To help protect your mailbox from unauthorized access, close all browser windows when you finish using Outlook Web Access.");
    }
    </SCRIPT>
    <FRAMESET OnUnload="WarnOnLogOff()" framespacing="3" cols="190,*"><FRAME bordercolor="#3D5FA3" name="navbar" title="Navigation" src="./?Cmd=navbar" marginheight="0" marginwidth="0" scrolling="auto" border="1"><FRAME name="viewer" title="Contents" src="%E6%94%B6%E4%BB%B6%E5%8C%A3/?Cmd=contents" scrolling="auto">
    <NOFRAMES>
    <BODY><P>This page uses frames, but your browser doesn't support them.</P></BODY>
    </NOFRAMES>
    </FRAMESET>
    </HTML>

     

    Thanks,

    Ecroo

    Thursday, April 22, 2010 2:27 AM
  • Also, the details about google exchange:

    After send request with FolderSync and synckey(0)

    the response:

    <FolderSync>
        <Status>1</Status>
        <SyncKey>1xxxxxxxxx4</SyncKey>
        <Changes>
        <Count>14</Count>
        <Add>
        <ServerId>Contact:DEFAULT</ServerId>
        <ParentId>0</ParentId>
        <DisplayName>Contacts</DisplayName>
        <Type>9</Type>
        </Add>
        <Add>
        .
        .
        .
        </Add>
        </Changes>
    </FolderSync>

    So I use the ServerId as CollectionId in the next request

    and all the other request and response are described in the first post

    does I use wrong papameters in my xml request?

    BTW, I can send ForderCreate and Sync with add command to add new contact successful.

    what's the problem?

     

    Many thanks again

    Ecroo

    Thursday, April 22, 2010 7:45 AM
  •  

    Ecroo, after reviewing the XML in your initial post and comparing that to the specification in MS-ASCMD I see 2 syntactical errors and one other issue that I think might be contributing to the problem that you are seeing.

     

    MS-ASCMD 2.2.1.19.1.5 WindowSize

    In your XML you are not using the correct closing element tag. It should be </WindowSize>, not </Windows>.

     

    MS-ASCMD 2.2.1.19.1.26 Class

    In your XML you are specifying the Class value as 'Contact'. That is not a valid value according to the document. It should be 'Contacts'.

     

    MS-ASCMD 2.2.1.19.1.13 GetChanges

    According to the specification, you should not be including the GetChanges element in your initial request when the SyncKey value is 0. Per the doc, "A <Status> value of 4 is returned if <GetChanges> is set to True (1) when the <SyncKey> value is 0." While your XML does not explicitly set GetChanges to a value of 1, 1 is the default value if left empty. In your follow up post I see that you are not getting a response with a status of 4, but I think it's worth mentioning anyway.

     

    You might also have some luck posting your question to the Google Windows Mobile Devices forum if you haven't already. Your request is being sent to Google's implementation of the ActiveSync protocol against Gmail which is not a Microsoft Exchange server.

     

    In regards to your second question, that looks to be more of an Exchange or IIS  configuration issue. Are you manually building this request? You might try posting that portion of your question to the IIS or Exchange forums.


    Josh Curry (jcurry) | Sr. Support Escalation Engineer | US-CSS DSC Protocols Team
    Thursday, April 22, 2010 3:56 PM
    Moderator
  • Thanks for your answer~

    as you mention,

    1. </WindowSize>. Fisrt, I am sorry for this. because this is my type error in the first post. I am sure that the request I sent to server is </WindowSize>

    2. I also try not to include <GetChange/> tag in my XML when synckey value is 0, but teh result is the same.

    3 Yse. I manually built this request to the Exchange server, and I will try to post this issue to those forums

    Thanks a lot~

    Ecroo

     

    Thursday, April 22, 2010 11:44 PM
  • Finally, I can access the Exchange Server and get the response wiht FolderSync hierarchy.

    I found the problem is the User-Agent in the http header.

    now I use the parameter as User-Agent: Android/0.3.

    But there is another problem occurred.

    After I got the folder serverid

    i send a request:

    <?xml version="1.0" encoding="utf-8"?>
    <Sync>
    <Collections>
    <Collection>
    <Class>Contacts</Class>
    <SyncKey>0</SyncKey>
    <CollectionId>8af59beb740189438e1e649a3731a143-92bae84</CollectionId>
    <WindowSize>100</WindowSize>
    <GetChanges>0</GetChanges>
    </Collection>
    </Collections>
    </Sync>

     

    But, as Josh Curry mentioned.

    I got a response with  <Status>4</Status>

    But  I don't what's the problem is?

    I have already set GetChanges to 0.

     

    could anyone know what's the problem

    Thanks~


    Friday, April 23, 2010 2:57 AM
  • about this XML, the order is wrong.

    so, I modify it to:

    <?xml version="1.0" encoding="utf-8"?>
    <Sync>
    <Collections>
    <Collection>
    <Class>Contacts</Class>
    <SyncKey>0</SyncKey>
    <CollectionId>8af59beb740189438e1e649a3731a143-92bae84</CollectionId>
    <GetChanges>0</GetChanges>
    <WindowSize>100</WindowSize>
    </Collection>
    </Collections>
    </Sync>

    but the response is still <Status>4</Status>

    Friday, April 23, 2010 7:54 AM
  • I found that no matter what I put in my request body, I will alwaly receive a status 4.
    That is if I put a normal WBXML, I will receive a status, and if I put any string like "abcde", I will also receive a status 4!

    Is this situation right??

    Does it indicate that my wbxml may be wrong??
    Or the parametes in the request is wrong??

    Can anyone help me to check the xml and wbxml?
    Thanks very much!!
    Here is my original xml:
    <?xml version="1.0" encoding="utf-8"?>
    <Sync>
    <Collections>
    <Collection>
    <Class>Calendar</Class>
    <SyncKey>0</SyncKey>
    <CollectionId>1</CollectionId>
    <DeletesAsMoves/>
    <GetChanges>0</GetChanges>
    </Collection>
    </Collections>
    </Sync>

    and the correspond WBXML is:
    03 01 6A 00 45 5C 4F 50 03 43 61 6C 65 6E 64 61 72 00 01 4B 03 30 00 01 52 03 31 00 01 1E 53 03 30 00 01 01 01 01

    is it right?

    if this is right, what might be the problem is?????

    Thanks~~

    Ecroo

    Friday, April 23, 2010 2:16 PM
  •  

    Ecroo, you mentioned that you are able to successfully send the request to the MS exchange server now. So, concerning the last bit of XML you posted, are you submitting this to the Google mail server or the MS Exchange Server? I am going to assume that you are sending this to a Microsoft Exchange Server since that is the implementation covered by the MS-ASCMD document.

     

    After reviewing the XML Schema for the Sync Request I believe that your XML should look like this:

     

    <?xml version="1.0" encoding="utf-8"?>
    <Sync>
         <Collections>
              <Collection>

                   <SyncKey>0</SyncKey>

                   <CollectionId>8af59beb740189438e1e649a3731a143-92bae84</CollectionId>

                   <GetChanges>0</GetChanges>

                   <Options>

                        <Class>Contacts</Class>
                   </Options>
              </Collection>
         </Collections>

    </Sync>

     

    The key thing I noticed is that the Class element must be contained in an Options element. The WindowSize element can be omitted since you are using the default value of 100.

     

    Please let me know if this makes any difference.


    Josh Curry (jcurry) | Sr. Support Escalation Engineer | US-CSS DSC Protocols Team
    Friday, April 23, 2010 3:24 PM
    Moderator
  • Hi~Josh, I sent this XML to MS Exchange Server .

    I try the XML you provided but the response is still <status> 4 </status>.

    here is my request:

    POST https://webmail.xxx.xxx/Microsoft-Server-ActiveSync?Cmd=Sync&User=xxx&DeviceId=v140Device&DeviceType=SmartPhone

    Header:

    MS-ASProtocolVersion: 2.5

    Connection: keep-alive

    User-Agent: Andriod/0.3

    Content-Type: application/vnd.ms-sync.wbxml

    Authorization: Basic XXXXsome based64 stringXXXXXXX

     

    and the WBXML convertd from XML you provided:

    03 01 6A 00 45 5C 4F 4B 03 30 00 01 52 03 38 61 66 35 39 62 65 62 37 34 30 31 38 39 34 33 38 65 31 65 36 34 39 61 33 37 33 31 61 31 34 33 2D 39 32 62 61 65 38 34 00 01 53 03 30 00 01 57 50 03 43 6F 6E 74 61 63 74 73 00 01 01 01 01 01

     

    that is

    <?xml version="1.0" encoding="utf-8"?>
    <Sync>
         <Collections>
              <Collection>

                   <SyncKey>0</SyncKey>

                   <CollectionId>8af59beb740189438e1e649a3731a143-92bae84</CollectionId>

                   <GetChanges>0</GetChanges>

                   <Options>

                        <Class>Contacts</Class>
                   </Options>
              </Collection>
         </Collections>

    </Sync>

     

     

    and the response is

    <?xml version="1.0" encoding="utf-8"?>
    <Sync>

    <status>4</status>

    </Sync>

     

    Does I use the parameters in the request?

     

    Thanks~

    Friday, April 23, 2010 3:57 PM
  • Ecroo, Thank you for the additional information. One thing jumped out at me right away that I don't think you mentioned previously, is that you are setting the MS-ASProtocolVersion to 2.5. That is not a supported version and the current version of the MS-ASCMD document is for version 14. Only version 12.1 or newer is supported.

     

    If you are sending this request to a MS Exchange 2007 server you will need to use 12.1, if it's running Exchange 2010 you will need to use 14.

     

    If you recall in my previous post I moved the Class element into the Options element. There is a note in the Appendix that this is specific to version 14. If you need to use version 12.1 you will need to remove the Options element and put the Class element back under the Collection element.


    Josh Curry (jcurry) | Sr. Support Escalation Engineer | US-CSS DSC Protocols Team
    Friday, April 23, 2010 6:19 PM
    Moderator
  • Josh~

    Thanks very much~

    But the server I connected is Exchange 2003.

    Could you kindly tell me where can I find the document about version 2.5 ?

    I only found the document of Exchange 2007 and 2010.

    I think 2003 is also support Exchange ActiveSync, because I can do this via my windows mobile phone.

    or what is the command that I should send to server 2003?

    where can I find this information?

    Many thanks again.

    Ecroo

    • Edited by Ecroo Saturday, April 24, 2010 3:01 AM
    Friday, April 23, 2010 11:28 PM
  • I now can send request to the server using the following XML:

    <?xml version="1.0" encoding="utf-8"?>
    <Sync>
    <Collections>
    <Collection>
    <Class>Contacts</Class>
    <SyncKey>0</SyncKey>
    <CollectionId>8af59beb740189438e1e649a3731a143-92bae84
    </CollectionId>
    </Collection>
    </Collections>
    </Sync>

    It must not include the <GetChanges> tag, or a status 4 will return in my test.

    and I can get a new sync key from Exchange server as MS-ASCMD document described. And then, I send this new synckey to server again, but, I don't receive any contact record in my contact, I also try calender and email, the situations are the same.

    In MS-ASCMD document, it described that if sync process start with a synckey 0, it would conduct a full sync to get all content of that folder.

    But I don't receive any content...  how to do it??

     

    Ecroo


    Saturday, April 24, 2010 1:00 AM
  • I tested many times and found that if I store the synckey and then send this synckey to server after a long interval(may be one day). The exchange server cannot recognize that synckey.

    It is not reasonable. If the server cannot recognize the latest sync key, how could the client to keep the latest content? Client may not send sync request every monent. He may shout down the device or disconnect to the Internet. If the server does not keep the sync key, client should conduct an initial sync every time. It does not make sense. Or..what  steps I need to do to enforce the server to keep the related information? what document I can refer to?? I don't see any thing about this issue in the documents:MS-ASCMD, MS-ASHTTP and MS-ASAIR.

    Thanks 

    Ecroo

    Monday, April 26, 2010 2:12 AM
  • Hi Ecroo,

    As Josh pointed out on his April 23rd post, and to reiterate, we support Exchange ActiveSync (EAS) 12.1 and greater as part of the Interoperability Principles.   If you want to pursue content for EAS 2.5 you will need to contact Microsoft’s IP licensing team.  Licensing information for EAS can be found here: http://www.microsoft.com/about/legal/en/us/IntellectualProperty/IPLicensing/Programs/ExchangeActiveSyncProtocol.aspx

    If you require technical support for EAS 2.5 you will need to go through the Premier Support organization, here: http://www.microsoft.com/microsoftservices/en/us/support.aspx

    Regards,

    Mark Miller

    Escalation Engineer

    US-CSS DSC PROTOCOL TEAM


    Tuesday, April 27, 2010 9:48 PM
  • Hi Mark,

    Thanks for your information.

    And I try these tests on exchange 2007 server now.

    Ecroo

    Wednesday, April 28, 2010 12:10 AM