Access web services from ASP.NET

From: Taras Overchuk (anonymous_at_discussions.microsoft.com)
Date: 10/27/03


Date: Mon, 27 Oct 2003 06:41:17 -0800

Hi!

I need to access web service form ASP.NET application with credentials of connected user (Integrated Windows Authenticated)
I think I have to do next steps:
1) Create proxy class for web secvice. (I did it with "Add web reference" dialog box. Visual studio created for me some class (MyProxy) derived from "System.Web.Services.Protocols.SoapHttpClientProtocol" class)
2) In place where I need to call web method I have to write somthing like this:
/*ms-help://MS.VSCC.2003/MS.MSDNQTR.2003JUL.1033/dnnetsec/html/SecNetch11.htm)*/
MyProxy my_proxy = new MyProxy();
IDictionary channelProperties;
channelProperties = ChannelServices.GetChannelSinkProperties(my_proxy);
channelProperties ["credentials"] = CredentialCache.DefaultCredentials;
my_proxy.GetSomeData();

In this code an exception is generated with message "Object reference not set to an instance of an object".

What am I doing wrong?

(Maybe it's important: I do it from WebPart for SharePoint)