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

T

THTB

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
 

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,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top