我正在尝试使用Android中的Exchange 2010为您的会议应用程序构建一本书。 我正在使用CorporateContacts来熟悉activesync。 到目前为止,我已设法使ResolveRecipients,SendMail和FolderSync命令正常工作。但是,当我尝试 上传会议请求我收到400错误请求错误。我正在使用this 作为参考。
我的xml
<?xml version="1.0" encoding="utf-8"?>
<Sync xmlns:calendar="Calendar" xmlns="AirSync">
<Collections>
<Collection>
<SyncKey>1425334024</SyncKey>
<CollectionId>4</CollectionId>
<GetChanges>1</GetChanges>
<Commands>
<Add>
<ClientId>5644895</ClientId>
<ApplicationData>
<calendar:TimeZone>tv7//ygAVQBUAEMAKwAwADUAOgAzADAAKQAgAEMAaABlAG4AbgBhAGkALAAgAEsAbwBsAGsAYQB0AGEALAAgAE0AdQAAAAAAAAAAAAAAAAAAAAAAAAAAACgAVQBUAEMAKwAwADUAOgAzADAAKQAgAEMAaABlAG4AbgBhAGkALAAgAEsAbwBsAGsAYQB0AGEALAAgAE0AdQAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</calendar:TimeZone>
<calendar:StartTime>20130109T100000Z</calendar:StartTime>
<calendar:Subject>TestMeeting</calendar:Subject>
<calendar:UID>040000008200E90074C5B7101A82E0080000000036BD76EAAAD5CA01000000000000000010000000C45185F686A5D542B20BF2CE2F477D55</calendar:UID>
<calendar:Attendees>
<calendar:Attendee>
<calendar:Email>Test@test.com</calendar:Email>
<calendar:Name>JohnDoe</calendar:Name>
<calendar:AttendeeStatus>0</calendar:AttendeeStatus>
<calendar:AttendeeType>1</calendar:AttendeeType>
</calendar:Attendee>
</calendar:Attendees>
<calendar:Location>My Office</calendar:Location>
<calendar:EndTime>20130109T110000Z</calendar:EndTime>
<calendar:Sensitivity>0</calendar:Sensitivity>
<calendar:BusyStatus>1</calendar:BusyStatus>
<calendar:AllDayEvent>0</calendar:AllDayEvent>
<calendar:MeetingStatus>1</calendar:MeetingStatus>
</ApplicationData>
</Add>
</Commands>
</Collection>
</Collections>
</Sync>
CreateHTTPPost功能
private HttpPost createHttpPost(String uri, String requestXML,
boolean includePolicyKey) throws Exception {
// Set the common headers
HttpPost httpPost = new HttpPost(uri);
httpPost.setHeader("User-Agent", "Android");
httpPost.setHeader("Accept", "*/*");
httpPost.setHeader("Content-Type", "application/vnd.ms-sync.wbxml");
//httpPost.setHeader("Content-Type", "message/rfc822");//message/rfc822
// If we are connecting to Exchange 2010 or above
// Lets tell the Exchange server that we are a 12.1 client
// This is so we don't have to support sending of additional
// information in the provision method
if(getActiveSyncVersionFloat() >= 14.0)
httpPost.setHeader("MS-ASProtocolVersion", "12.1");
// Else set the version to the highest version returned by the
// Exchange server
else
httpPost.setHeader("MS-ASProtocolVersion", getActiveSyncVersion());
//Log.d(TAG, mActiveSyncVersion);
httpPost.setHeader("Accept-Language", "en-us");
httpPost.setHeader("Authorization", mAuthString);
// Include policy key if required
if (includePolicyKey)
httpPost.setHeader("X-MS-PolicyKey", mPolicyKey);
// Add the XML to the request
if (requestXML != null) {
//Log.d(TAG, requestXML);
// Set the body
// Convert the XML to WBXML
ByteArrayInputStream xmlParseInputStream = new ByteArrayInputStream(
requestXML.toString().getBytes());
java.io.ByteArrayOutputStream output = new java.io.ByteArrayOutputStream();
wbxml.convertXmlToWbxml(xmlParseInputStream, output);
byte[] bytes = output.toByteArray();
ByteArrayEntity myEntity = new ByteArrayEntity(bytes);
myEntity.setContentType("application/vnd.ms-sync.wbxml");
httpPost.setEntity(myEntity);
}
return httpPost;
}
我遗失了哪些标题?或者xml的任何错误?如果有人可以发光,我将非常感激。 我在标题中使用activesync版本12.1。
答案 0 :(得分:0)
xml看起来很好。确保从xml正确转换为wbxml。要仔细检查,请尝试转换回xml并查看是否返回原始字符串。