Problem Found: Part of the response (Message body) contains "" which is an invalid XML character. Any idea how to remove it?
I'm using Exchange Web Services to pull in a large number of emails from an Inbox. It worked for the first 1141 emails, but it is failing on 1142 (Skipping ahead to 1143 works fine). I have no idea why it's failing to retrieve the email, but the error I'm getting is this:
Uncaught SoapFault exception: [Client] looks like we got no XML document
I outputted the response XML to a file for 1142 and 1143, and the only difference was the ItemId line (As expected).
The email does exist in the Inbox, although it contains some odd characters (Represented by those weird square symbols).
I am using a slightly modified version of the php-ews library. Here is part of my code:
<?php
$response = $ews->FindItem($Request);
$items = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Message;
foreach ( $items as $item ) {
$ItemRequest = new EWSType_FindItemType();
$ItemRequest->ItemShape = new EWSType_ItemResponseShapeType();
$ItemRequest->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$ItemRequest->ItemShape->BodyType = EWSType_BodyTypeResponseType::TEXT;
$ItemRequest->ItemShape->BodyTypeSpecified = true;
$ItemRequest->ItemIds = new EWSType_NonEmptyArrayOfBaseItemIdsType();
$ItemRequest->ItemIds->ItemId = new EWSType_ItemIdType();
$ItemRequest->ItemIds->ItemId->Id = $item->ItemId->Id;
$response = $ews->GetItem( $ItemRequest ); // Code fails here
}
So I have no idea why the request would fail. I've tried adding the option "exceptions" => 0, "trace" => 1, an d I can see that __last_response DOES contain the response I was expected. Why did it mysteriously fail even though I got back the right response?