php-ews
php-ews copied to clipboard
Contact/find.php throws error
Hello James
I am using your new library
I tried your contact/find.php example and its giving me error
Fatal error: Uncaught SoapFault exception: [soap11:Client] The request failed schema validation: The required attribute 'Traversal' is missing. in
another thing is autodiscover code is returning server version as Exchange2007_SP3 but if I use constant VERSION_2007_SP3 it throws error invalid server version.
The Exchange2007_SP3 constant was removed a while ago, so you shouldn't be able to use it if you're using an updated version of the library. I did, however, notice that it's use was not removed from the Autodiscover class, which I have resolved on master and will be included in the next beta (beta.3).
Have you altered the code in the contact/find example? The basic example should not require a traversal type.
I also have an error with finding a contact, and I have added the traversal enumeration. To note, I am testing this in a method, and authentication with the client in a parent class, hence the $this->client. Here is the code:
$request = new FindItemType();
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->ContactsView = new ContactsViewType();
// Find contacts in the contacts folder.
$folder_id = new DistinguishedFolderIdType();
$folder_id->Id = DistinguishedFolderIdNameType::CONTACTS;
$request->ParentFolderIds->DistinguishedFolderId[] = $folder_id;
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$response = $this->client->FindItem($request);
return $response;
This produces an error:
Uncaught SoapFault exception: [a:ErrorSchemaValidation] The request failed schema validation:
The element 'ItemShape' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has incomplete content.
List of possible elements expected: 'BaseShape' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. in \vendor\php-ews\php-ews\src\Client.php:1631 Stack trace: #0
\vendor\php-ews\php-ews\src\Client.php(1631): SoapClient->__call('FindItem', Array)
#1 \vendor\php-ews\php-ews\src\Client.php(1631): jamesiarmes\PhpNtlm\SoapClient->FindItem(Object(jamesiarmes\PhpEws\Request\FindItemType))
#2 \vendor\php-ews\php-ews\src\Client.php(670): jamesiarmes\PhpEws\Client->makeRequest('FindItem', Object(jamesiarmes\PhpEws\Request\FindItemType))
#3 \test\emailintegration\src\Contact.php(173): jamesiarmes\PhpEws\Client->FindItem(Object(jamesiarmes\PhpEws\Request\FindItemType))
Fatal error on line 1631 in file \vendor\php-ews\php-ews\src\Client.php, PHP 5.6.23 (WINNT)
I found the answer, I did add the traversal but I also needed to add a BaseShape. Here is what works for me:
// Build the request.
$request = new FindItemType();
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->ContactsView = new ContactsViewType();
// Find contacts in the contacts folder.
$folder_id = new DistinguishedFolderIdType();
$folder_id->Id = DistinguishedFolderIdNameType::CONTACTS;
$request->ParentFolderIds->DistinguishedFolderId[] = $folder_id;
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$response = $this->client->FindItem($request);
@nagesh314 Check and see if the above helps you as well. Adding the Traversal and the BaseShape gave me results above.
Also, to note, I had looked at the example: https://msdn.microsoft.com/en-us/library/office/jj220498(v=exchg.80).aspx. This showed a BaseShape with an additional property in the XML request. I could be more specific about the BaseShape property, however, all_properties worked.
I today found some time to catch up with that subject.
For some reason the code throws an error:
'ContactsView' ist not supported for assigned elements.
What does that tell me?