A few weeks back I wrote a post on how to mix Windows Azure and SharePoint Online called Custom code with SharePoint Online and Windows Azure. Since then both Windows Azure and SharePoint online have had some updates.

First of all you no longer need to create the bindings in the code to make it fully trusted. Good to know but it does not affect the solution.

A Bug in SharePoint Online Web Services

More important is the fact that you cannot longer use the Visual Studio Add Service Reference function and add the services from your SharePoint Online site to your solution. You will end up with an error like this:

Add Service Reference Error

It says that it cannot recognize the document format of the Lists.asmx?WSDL and Lists.asmx?disco documents. Why?

If you open up the Lists web service in a browser you get the standard auto generated ASMX page:

Lists.asmx

From this page you can check out all the web service operations, but when you click on the Service Description link, which would take you to the /_vti_bin/Lists.asmx?WSDL page, which contains the definitions of the web service and it’s operations you get an error. The same errors that Visual Studio gets.

Lists.asmx?WSDL Fail!

This page should contain XML and look like this (taken from a normal WSS 3.0 installation):

Lists.asmx?WSDL working!

So what is happening in SharePoint Online!? If you take a look at the source of the faulty WSDL page you will see an error message saying something like this:

The requested page does not contain a link to the Microsoft Online Services Privacy Statement. The page cannot be displayed until a link to the Privacy Statement is added. Please notify your SharePoint site administrator. Only the site administrator or site owner can add the Privacy Statement. For information on adding the statement, see: Add the Privacy Statement to your SharePoint Online Site.

This error message is shown on all ASPX pages in SharePoint Online that does not contain a link to the Microsoft Online Services Privacy Statement, which is a requirement in SharePoint Online. The link in the error message tells you how to include this message in your custom ASPX pages.

But, we just looked at a ASMX page, I can’t have statements like this in my web services!?

Let’s dig a little bit deeper into the SharePoint 12-folder. In the ISAPI folder you have the Lists.asmx file, as well as a Listsdisco.aspx and a Listswsdl.aspx file. Normally in ASP.NET when you create your own ASMX file the WSDL and DISCO will be created automatically but SharePoint silently uses these other two files, instead of creating them at runtime. Because these two files are ASPX files you need to have that Privacy Statement.

This is in my opinion a real bug in SharePoint Online, and should be corrected as soon as possible.

How to work around the bug?

It’s pretty easy to work around this bug. All you have to do is when adding the service reference is to get the web service from a normal SharePoint installation (WSS or MOSS) and then in your service binding point to your SharePoint Online address.

I hope that the Microsoft Online team come up with a solution to this problem as soon as possible, since it will cause headache for a lot of developers.