Access web services from ASP.NET

T

Taras Overchuk

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)
 
T

Taras Overchuk

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)

But it's anyway interesting, why previous sample don't work.
 
E

Ed Smith[msft]

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


--------------------
Thread-Topic: Access web services from ASP.NET
thread-index: AcOcp73/6me75RrvQwivobVTWXDm0w==
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
From: "=?Utf-8?B?VGFyYXMgT3ZlcmNodWs=?="
References: <[email protected]>
Subject: RE: Access web services from ASP.NET
Date: Mon, 27 Oct 2003 08:31:15 -0800
Lines: 8
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet.security
NNTP-Posting-Host: TK2MSFTCMTY1 10.40.1.180
Path: cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.security:7314
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security

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)

But it's anyway interesting, why previous sample don't work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top