0

I work with Exchange Server 2010 trought EWS Managed API. When I do a request FindItem I get an error from server - "ErrorIncorrectSchemaVersion" "The request is valid but does not specify the correct server version in the RequestServerVersion SOAP header. Ensure that the RequestServerVersion SOAP header is set with the correct RequestServerVersionValue." But in XML I have specified a RequestServerVersionValue as Exchange2010. I also tried to specify Exchange2007, Exchange2007_SP1, Exchange2010_SP1 but nothing changed.

  <?xml version="1.0" ?> 
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <SOAP-ENV:Body>
- <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow">
- <ItemShape>
  <BaseShape xmlns="http://schemas.microsoft.com/exchange/services/2006/types">IdOnly</BaseShape> 
  </ItemShape>
  <IndexedPageItemView MaxEntriesReturned="100" Offset="0" BasePoint="Beginning" /> 
- <ParentFolderIds>
- <DistinguishedFolderId xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Id="calendar">
- <Mailbox>
  <EmailAddress>test@test1.com</EmailAddress> 
  </Mailbox>
 </DistinguishedFolderId>
  </ParentFolderIds>
  </FindItem>
- <ExchangeImpersonation xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
- <ConnectingSID>
 <PrimarySmtpAddress>test@test1.com</PrimarySmtpAddress> 
 </ConnectingSID>
  </ExchangeImpersonation>
  <MailboxCulture xmlns="http://schemas.microsoft.com/exchange/services/2006/types">US-en</MailboxCulture> 
  <RequestServerVersion xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2010" /> 
- <TimeZoneContext xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
- <TimeZoneDefinition Id="FLE Standard Time">
- <Periods>
  <Period Id="FLE Standard Time" /> 
  </Periods>
  </TimeZoneDefinition>
  </TimeZoneContext>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>
dream2work
  • 1,377
  • 2
  • 10
  • 18
  • Have you tried Fiddler to find request differences between the Delphi and C# / Java clients (WCF, SoapUI)? – mjn Jan 11 '13 at 11:13
  • I haven't. I have only Delphi client. Maybe somebody is familiar with Delphi and Exchange WSDL and has valid Delphi Unit generated from Exchange? Becouse my one is very buggy and some classes won't work correctly. – dream2work Jan 11 '13 at 13:34
  • SoapUI is a free and very popular SOAP testing tool which allows to execute SOAP requests, you only need to import the WSDL there and then invoke a method – mjn Jan 11 '13 at 13:41
  • I'm very interested how you work with Exchange Server 2010 through EWS Managed API and Delphi: http://stackoverflow.com/questions/13084508/it-is-possible-to-use-the-ews-managed-api-from-a-delphi-win32-vcl-app-and-how-t – Jan Doggen Jan 11 '13 at 14:40

1 Answers1

1

You have a block of XML that should be in a SOAP header, like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Header>
  <ExchangeImpersonation xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
    <ConnectingSID>
    <PrimarySmtpAddress>developer@[snip].nl</PrimarySmtpAddress> 
    </ConnectingSID>
  </ExchangeImpersonation>
  <MailboxCulture xmlns="http://schemas.microsoft.com/exchange/services/2006/types">US-en</MailboxCulture> 
  <RequestServerVersion xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2010" /> 
  <TimeZoneContext xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
    <TimeZoneDefinition Id="FLE Standard Time">
      <Periods>
        <Period Id="FLE Standard Time" /> 
      </Periods>
    </TimeZoneDefinition>
  </TimeZoneContext>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow">
    <ItemShape>
      <BaseShape xmlns="http://schemas.microsoft.com/exchange/services/2006/types">IdOnly</BaseShape> 
    </ItemShape>
    <IndexedPageItemView MaxEntriesReturned="100" Offset="0" BasePoint="Beginning" /> 
    <ParentFolderIds>
      <DistinguishedFolderId xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Id="calendar">
        <Mailbox>
          <EmailAddress>developer@[snip].nl</EmailAddress> 
        </Mailbox>
      </DistinguishedFolderId>
    </ParentFolderIds>
  </FindItem>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>    

Running this will give you your next error ;-)
ErrorTimeZone - The Bias attribute for the period is set to null

And I found this testing with SoapUI (hint!)

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
  • This XML is fully generated by Delphi. I only cath it in OnBeforeExecute event. Right now I use WSDL from Excahnge 2007 to comunicate with Exchange 2010 and it works better. I send FindItem and even get valid XML with items, but Delphi returns FindItemResponse object with wrong properties. And I really don't know what to do next. Maybe it would be better to work with XML directly instead of this ugly classes that Delphi has generated from WSDL. – dream2work Jan 11 '13 at 19:20
  • I have given up on trying to use the WSDL. Sending the XML works reasonably but I never managed to parse the results with the code from the imported type library. – Jan Doggen Jan 11 '13 at 21:27
  • How did you manage to work with Exhange server via soapUI? I set correct username and password but got a "HTTP/1.1 401 Unauthorized" error. – dream2work Jan 14 '13 at 09:10
  • Is this already in the WSDL import stage (Add WSDL)? I don't remember what credentials I used there, but they should be the same as what I'm using in the teststeps. In the teststeps I have authorisation type 'Global HTTP settings' with username, password, domain filled in. The endpoint points to the .asmx not the .wdsl. And don't forget to add an extra Content-Type header "text/xml; charset=utf-8" without the quotes - EWS does not understand the official quoted "utf-8". – Jan Doggen Jan 14 '13 at 09:27
  • Note that the WSDL import is big. SoapUI (or better the Java runtime) will run out of memory and not all requests will be parsed (the last few will have no XML code). I had to install 64 bit Java to circumvent this. – Jan Doggen Jan 14 '13 at 09:27