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. Advertisements

  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. Advertisements

  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. Advertisements

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. Martin
    Replies:
    5
    Views:
    529
    Raheel Hussain
    Jun 1, 2004
  2. Nick
    Replies:
    1
    Views:
    7,121
    Alvin Bruney - ASP.NET MVP
    Sep 12, 2005
  3. tg
    Replies:
    0
    Views:
    745
  4. Steve B.
    Replies:
    0
    Views:
    490
    Steve B.
    Nov 28, 2006
  5. va
    Replies:
    0
    Views:
    322
  6. Dave

    Secure web services used by ASP & ASP.NET

    Dave, Oct 22, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    204
  7. Tim Scarfe

    ASP.NET Web Services. Web Method CacheDuration Issue.

    Tim Scarfe, Feb 4, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    193
    Tim Scarfe
    Feb 4, 2004
  8. John
    Replies:
    4
    Views:
    812
Loading...