I'm trying to build a simple Exchange ActiveSync client.
I'm using a simple Python script that sends an initia开发者_开发问答l sync email command, while connecting to an Exchange 2010 SP1 .
In the request body I'm send the following XML encoded as WBXML (using pywbxml):
<?xml version="1.0"?>
<!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
<Sync>
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>0</SyncKey>
<CollectionId>5</CollectionId>
</Collection>
</Collections>
</Sync>
The server answers with a 200 OK
but returns a Status code: 4
<?xml version="1.0"?>
<!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
<Sync>
<Status>4</Status>
</Sync>
I couldn't find any documentation on this status code in the official docs. How can I figure this out?
The Sync
status code value 4
represents a client protocol error. It is documented on this MSDN page.
A correct Sync
command would look more like the following, assuming that Inbox
has an ID of 5 (converted from WBXML to a readable XML):
<?xml version='1.0' ?>
<Sync>
<Collections>
<Collection>
<SyncKey>0</SyncKey>
<CollectionId>5</CollectionId>
<Options>
<FilterType>5</FilterType>
<BodyPreference>
<Type>1</Type>
<TruncationSize>32768</TruncationSize>
</BodyPreference>
</Options>
</Collection>
</Collections>
</Sync>
The EAS protocol requires that you Provision
and FolderSync
first, however. You can't just jump straight to a Sync
. The basic protocol sequence is described here.
精彩评论