jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
567 stars 302 forks source link

Always getting "server version is invalid" while connecting to AWS WorkMail #552

Open GBeushausen opened 5 years ago

GBeushausen commented 5 years ago

Version (e.g. 1.0, dev-master): 1.0 PHP version: 7.2 Microsoft Exchange version: AWS Workmail (Supports 2013, 2010)

Description of problem: No matter what i enter as the version, or as it's optional if i omit the version completely i always get the following error message:

Fatal error: Uncaught SoapFault exception: [a:ErrorInvalidServerVersion] The specified server version is invalid. in /mnt/hgfs/www/code/vendor/php-ews/php-ews/src/Client.php on line 1631

Example request:

$start_date = new DateTime('January 1 00:00:00');
$end_date = new DateTime('December 31 23:59:59');
$timezone = 'Eastern Standard Time';

$client = new Client("ews.mail.eu-west-1.awsapps.com", "xxx", "xxx", Client::VERSION_2010);
$client->setTimezone($timezone);
$request = new FindItemType();
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
// Return all event properties.
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
$folder_id = new DistinguishedFolderIdType();
$folder_id->Id = DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderIds->DistinguishedFolderId[] = $folder_id;
$request->CalendarView = new CalendarViewType();
$request->CalendarView->StartDate = $start_date->format('c');
$request->CalendarView->EndDate = $end_date->format('c');
$response = $client->FindItem($request);