Posts Tagged ‘web services’

SharePoint Designer 2010 – list/library There are no items to show in this view – ListData.svc woes

Thursday, November 8th, 2012

This is one of those SharePoint errors. You know the ones.

Background

I was trying to use SharePoint Designer to customise a list. I opened up SharePoint Designer, and, although I could connect to the site itself, when clicking on the lists/libraries folder, you get a message saying:

“There are no items to show in this view”.

Weird. I tried this on various other web applications (even on the same server) and everything was working fine.

Info

I spent ages looking at the settings between the two web applications – checking Alternate Access Mappings and DNS entries, IIS site bindings, authentication, permissions and everything – and all was fine and dandy. What I soon uncovered is that SPD is relying on a web service to get the List data. This particular service is

http://[yoursite]/_vti_bin/ListData.svc

You can put that address in your browser, and, if all is OK, it will spit out a load of XML for you. But in the case of my “broken” web app – the browser either just choked, no error, no 404 – just a bog standard “IIS has died” type screen, or alternatively I was given endless login prompts that never went away (a la the Disable Loopback shenanigans).

Cue more faffing around to try and find the issue – permissions, server config, backconnectionhostnames and… no. Then I tried a bunch of the other .svc and .asmx files in the _vti_bin folder (e.g., http://[yoursite]/_vti_bin/Client.svc) – and, surprisingly, these were all moreorless OK. So it had to be something to do with ListData.svc, or, more accurately, the list data it was trying to return.

The Solution

After Googling the google out of Google, I found out that you could append parameters to the URL to get specific information on the lists. So for instance, you could go to:

http://[yoursite]/_vti_bin/ListData.svc/Announcements

and this would give you list items in the Announcements list. And yep – on my broken web application, some lists were actually returning XML. So what this clearly pointed to was – drumroll – a broken list somewhere. After a bit of trial and error and head scratching, I found a list, that showed up in All Site Content, but that actually was dead.

(I have a feeling that the feature that deployed it had been removed, but left the list in place. This was on a dev server that has all sorts of junk deployed and retracted.)

But of course you can’t delete the list via the UI… but with a bit of powershell you can:

$web = Get-SPWeb http://[yoursite]
$list = $web.Lists["Your Broken List"]
$list.Delete()

This kills the list, and -hallelujah – ListData.svc springs in to life again, bringing with it, SharePoint Designer.

Configuring certificates and trust in SharePoint 2010 for accessing Exchange Web Services

Wednesday, November 9th, 2011

Exchange is built on web services and as I posted about a while about accessing EWS from SharePoint can be pretty neat. There is a managed API to make your life even easier. However, one issue you may come across is actually getting SharePoint and Exchange to talk nicely to each other. This will walk you through some of the steps required to get things going.

(more…)

Exchange Web Services and reading an EmailMessage to memory

Friday, July 1st, 2011

The Exchange Web Services Managed API is a great tool for exposing Exchange Web Services to a .NET programming environment. You are able to work with all the key features of an Exchange Mailbox, such as downloading messages. In my particular case, I’ve been capturing emails and storing them in a SharePoint document library.

The upload to SharePoint can be achieved by passing in a MemoryStream object – that is, you read an EmailMessage to memory, and then upload it to SharePoint. The FileAttachment object has a neat Load() method which allows you to read a FileAttachment to a MemoryStream:

foreach(FileAttachment fa in item.FileAttachments)
{
using(MemoryStream ms = new MemoryStream())
{
fa.Load(ms);

// Do something with your memorystream
}
}

Nice and simple. But for the EmailMessage itself, the process is a little different. You might ordinarily try and Serialise the EmailMessage object, but, unfortunately, this won’t work, as it’s not marked as Serializable. Instead, you have to access the MimeContent.Content property which is already a byte[]:

EmailMessage em = (EmailMessage)item;
PropertySet ps = new PropertySet(ItemSchema.MimeContent);
em.Load(ps);
using (MemoryStream ms = new MemoryStream(item.MimeContent.Content)) {
// etc.
}

You now have your EmailMessage in memory and do what you like with it. If you save it somewhere as a .eml file, then it will continue to behave and function like an email, with subject, sender, and attachments!