all groups > asp.net security > october 2003 >
You're in the

asp.net security

group:

Access web services from ASP.NET



Access web services from ASP.NET Taras Overchuk
10/27/2003 6:41:17 AM
asp.net security: 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?

RE: Access web services from ASP.NET Taras Overchuk
10/27/2003 8:31:15 AM
I've decided my own problem by next code:

my_proxy.PreAuthenticate = true;
my_proxy.Credentials = CredentialCache.DefaultCredentials;

(Look ms-help://MS.VSCC.2003/MS.MSDNQTR.2003JUL.1033/dnnetsec/html/SecNetch10.htm#secnetch10_webservicesecmodel)

RE: Access web services from ASP.NET edsmith NO[at]SPAM online.microsoft.com
10/27/2003 9:56:55 PM
You can do this in a simpler way with just the following line.
my_proxy.Credentials = Net.CredentialCache.DefaultCredentials

The credentials property of the proxy allow you to set this directly.

Hope this helps;
-Ed Smith
Microsoft VB.net team


--------------------
[quoted text, click to view]

my_proxy.PreAuthenticate = true;
my_proxy.Credentials = CredentialCache.DefaultCredentials;

(Look
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003JUL.1033/dnnetsec/html/SecNetch10.htm#
secnetch10_webservicesecmodel)

But it's anyway interesting, why previous sample don't work.
[quoted text, click to view]


--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

AddThis Social Bookmark Button