If you ever need to access one of the out-of-the-box SharePoint Web Services, you may find this post valuable to you. I was tasked to access a SharePoint Web Services from .NET code and I ran into several issues which are quite frustrating. I'm using MOSS SP1 on Windows Server 2008 and developing on Visual Studio 2008 SP1.
You should know that SharePoint 2007 Web Services are still ASMX web services whereas I'm more of a WCF fan.
First of all, if you are using host headers in your SharePoint sites, you will be awaken to a rude surprise that you won't be able to use "Add Service Reference" from Visual Studio 2008 to generate a proxy for the SharePoint Web Service.
You will encounter a symptom where you will be asked repeatedly to enter your crendentials for the web service in a Discovery Credential dialog box. Despite entering the right credentials, the dialog box will not dismiss and will continue to prompt you (until you smash your PC). If you choose to cancel the dialog box, you will not be able to generate the proxy for the Web Service.
You may try to use the "Add Web Reference" option as an alternative but you will receive near similar problems in generating the proxy. After two days of searching the Internet, I finally discovered that this is caused by the host headers. If you are using port numbers instead of host headers, you will not encounter this issue.
To rectify this problem, follow one of the methods listed in this KB Article. Once you are done, you should be able to "Add Service Reference" with no problems and you can proceed with your code.
Once you are ready to test calling the web service, you will again be slapped with another surprise! You may encounter the following exception:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'.
What you need to do is to modify some settings in the app.config of your .NET program. Locate the following security section in your binding (usually basicHttpBinding):
and replace it with
Then add the following line in your .NET code (my sample is in C#):
CopySoapClient proxy = new CopySoapClient();
proxy.ClientCredentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Impersonation;
Now everything should work fine.
Take note that if you try to bypass the host header problem by getting someone else to generate the proxy for you, you may encounter a more confusing version of the error message when you execute your code:
The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.
You must solve the host header problem in order to get everything working.
Home » SharePoint » WCF.&.WSS.Web.Services
Popular Post
-
V12 / 5.576 cc / 385 PS / 406 ft/lb (550 Nm) @ 4.000 / 0 - 62 mph (100 km/h): 6,6 s / Vmax: 155 mph (250 km/h) (click images for a larger ...
-
R4 / 1.169 cc / 50 PS / 68 ft/lb (92 Nm) @ 3.000 / 0 - 62 mph (100 km/h): 19,3 s (click images for a larger view)
-
We are delighted to report a new development. The ingenuity of the drivers of Aberdeen Cars never ceases to amaze! And delight! Here we see ...
-
With Easter on its way this weekend, I though it appropriate to explore the world of cute furry bunny art cars from around the world. There ...
-
Stream new song 20th Century by Swedish duo This Vision . Nice and catchy electro pop and...well that's pretty much it... 20th Cen...
-
After another year of 'fine tuning' Team Isetta returned to Hillsborough on the 26th of August 2012 to participate in the Parade ...
-
... сегодня у меня из машины стащили мой планшет Intuos3 =( не поленились просканили сигналку, стащили акуратно без взлома( у меня настроени...
-
Reports of the death of 4x4s greatly exaggerated A bit before Christmas, The Times splashed their front page with the almost gleeful headl...
-
the company selling these (Side Show http://www.sideshowtoy.com/ ) at Comic Con has the most incredible realistic models of everything in...
No comments:
Post a Comment