Getting Meeting by ICalUid in EWS

2019-08-09 23:29发布

问题:

I'm trying to send a bare bones SOAP request to my Exchange 2010 SP2 server, in order to find a meeting by ICalUid, inspired by this great answer by Glen.

'<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" ' +
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
'  <soap:Header>' +
'    <t:RequestServerVersion Version="Exchange2010_SP2"/>' +
'  </soap:Header>' +
'  <soap:Body>' +
'    <m:FindItem Traversal="Shallow">' +
'      <m:ItemShape>' +
'        <t:BaseShape>AllProperties</t:BaseShape>' +
'      </m:ItemShape>' +
'      <m:Restriction>' +
'        <t:IsEqualTo>' +
'          <t:ExtendedFieldURI DistinguishedPropertySetId="Meeting" PropertyId="0x03" PropertyType="Binary"/>' +
'          <t:FieldURIOrConstant>' +
'            <t:Constant Value="bbkpr55lqbc49acfg9objhg40g" />' +
'          </t:FieldURIOrConstant>' +
'        </t:IsEqualTo>' +
'      </m:Restriction>' +
'      <m:ParentFolderIds>' +
'        <t:DistinguishedFolderId Id="calendar" />' +
'      </m:ParentFolderIds>' +
'    </m:FindItem>'
'  </soap:Body>' +
'</soap:Envelope>';

This gives rise to the following error:

The 'PropertyId' attribute is invalid - The value '0x03' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:int' - The string '0x03' is not a valid Int32 value.

It is obviously not an Int32 value, but why is not the PropertyType="Binary" having any effect?

回答1:

Just use 3 instead of 0x03 in your request XML. The PropertyId in the request itself is defined as an int, and the XML definition doesn't allow hex encoding of int types.