Access web services from ASP.NET

Discussion in 'ASP .Net Security' started by Taras Overchuk, Oct 27, 2003.

  1. 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)
     
    Taras Overchuk, Oct 27, 2003
    #1
    1. Advertising

  2. 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.
     
    Taras Overchuk, Oct 27, 2003
    #2
    1. Advertising

  3. 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: <>
    >Subject: RE: Access web services from ASP.NET
    >Date: Mon, 27 Oct 2003 08:31:15 -0800
    >Lines: 8
    >Message-ID: <>
    >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.
    >



    --------------------------------------------------------------------
    This reply is provided AS IS, without warranty (express or implied).
     
    Ed Smith[msft], Oct 27, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick
    Replies:
    1
    Views:
    6,140
    Alvin Bruney - ASP.NET MVP
    Sep 12, 2005
  2. Anup
    Replies:
    1
    Views:
    2,793
    Mark Rae
    May 9, 2006
  3. imlakhani

    Web Services Restful Services

    imlakhani, Dec 16, 2009, in forum: Java
    Replies:
    1
    Views:
    426
    Jeffrey H. Coffield
    Dec 16, 2009
  4. va
    Replies:
    0
    Views:
    165
  5. John
    Replies:
    4
    Views:
    451
Loading...

Share This Page