Can't access Web Service thru DLL (but can thru Windows App)

Discussion in 'ASP .Net Web Services' started by THTB, May 17, 2007.

  1. THTB

    THTB Guest

    I've got a web service that I'm running on IIS 5.1 on my local machine.
    Using .Net 2.0.
    IIS Authentication access is Basic and I'm using a local user.
    I've created a windows application that can successfully access the web
    service using the following code:

    xTSMApplication.cApplication cApplication = new
    xTSMApplication.cApplication();
    // Set credentials
    NetworkCredential Credential = new NetworkCredential();
    Credential.UserName = "AppUser";
    Credential.Password = "App123";
    Credential.Domain = "MyDomain";
    CredentialCache CredCache = new CredentialCache();
    CredCache.Add(new Uri(cApplication.Url), "Basic", Credential);
    cApplication.Credentials = CredCache;
    // Call the Web Service
    xTSMApplication.AppResponse oAppResponse =
    cApplication.SaveApplication(App);

    However, when I create a class library (DLL) to access the web service using
    the same basic code (see below), I get an "401: Access Denied" exception.
    I've got a windows application that calls a method in my DLL. Please help!

    code from my DLL:

    public xTSMApplication.AppResponse SaveApp(xTSMApplication.NewApplication App)
    {
    xTSMApplication.cApplication cApplication = new
    xTSMApplication.cApplication();
    // Set credentials
    NetworkCredential Credential = new NetworkCredential();
    Credential.UserName = "AppUser";
    Credential.Password = "App123";
    Credential.Domain = "MyDomain";
    CredentialCache CredCache = new CredentialCache();
    CredCache.Add(new Uri(cApplication.Url), "Basic", Credential);
    cApplication.Credentials = CredCache;

    xTSMApplication.AppResponse oAppResponse =
    cApplication.SaveApplication(App);
    return oAppResponse;
    }

    Thanks for your help,
    Tom
     
    THTB, May 17, 2007
    #1
    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. Oliver Denzel

    Re: C# windows app distribution thru web

    Oliver Denzel, Jul 7, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,127
    Oliver Denzel
    Jul 7, 2003
  2. NGM
    Replies:
    0
    Views:
    2,355
  3. =?Utf-8?B?R2lhbmNhcmxv?=

    debug Windows app works but, not web app

    =?Utf-8?B?R2lhbmNhcmxv?=, Sep 26, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    338
    =?Utf-8?B?R2lhbmNhcmxv?=
    Sep 26, 2005
  4. ad
    Replies:
    1
    Views:
    311
    John Timney \(MVP\)
    Oct 23, 2006
  5. Alex Washtell via .NET 247

    Web Service + Anon Access, but getting 401 Access Denied Error

    Alex Washtell via .NET 247, Apr 5, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    226
    Mauro Ottaviani [MSFT]
    Apr 5, 2005
Loading...

Share This Page