views:

315

answers:

1

Hi,
Every time I run the following piece of code I get 'Unexpected end of XML document.' exception.
I have tried Microsoft's EWSEditor 1.6.1.1 and get the same exception which suggests it could be an exchange service issue.
Any ideas would be appreciated. Thank you.

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = true;
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
service.Url = new Uri(@"https://xxx.xxx.com/EWS/exchange.asmx");
ProcessItems(service);
MessageBox.Show("OK");

    private static void ProcessItems(ExchangeService exchangeService)
    {
        var offset = 0;
        const int pageSize = 10;
        var view = new ItemView(pageSize, offset);

        FindItemsResults<Item> findResults;
        do
        {
            SearchFilter.SearchFilterCollection searchFilterCollection = new SearchFilter.SearchFilterCollection(LogicalOperator.Or);
            searchFilterCollection.Add(new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));

            findResults = exchangeService.FindItems(WellKnownFolderName.Inbox, searchFilterCollection, view);

            foreach (var item in findResults)
            {
                MessageBox.Show(item.Subject);
            }
            offset += pageSize;
        }
        while (findResults.MoreAvailable);
    }

Unexpected end of XML document. at Microsoft.Exchange.WebServices.Data.EwsXmlReader.Read() at Microsoft.Exchange.WebServices.Data.SoapFaultDetails.ParseDetailNode(EwsXmlReader reader) at Microsoft.Exchange.WebServices.Data.SoapFaultDetails.Parse(EwsXmlReader reader, XmlNamespace soapNamespace) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadSoapFault(EwsServiceXmlReader reader) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.InternalExecute() at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest1.Execute() at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems[TItem](IEnumerable1 parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, Grouping groupBy, ServiceErrorHandling errorHandlingMode) at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(FolderId parentFolderId, SearchFilter searchFilter, ItemView view) at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(WellKnownFolderName parentFolderName, SearchFilter searchFilter, ItemView view)

A: 

I have very similar code and the same error, with the same trace response. Did you ever figure out what was going on?

Doug J