Hi, i have built my first service to attempt to schedule things, but i get HTTP 401 Unauthorized during the call to the webservice. How do i allow the service to consume the webservice with the current logged on domain account? Thats where the problem is i believe, and where i am confused.
Do i auth the webservice (this is all on an INTRAnet, btw) or do i auth the windows service? (IIS with IWA)
Right now this is being run from my workstation, not the webserver, and the Web Reference is populating and intellisensing fine in the designer. Should i install the service on the webserver??
in the Scheduler service code
i dont get the job.UserAccount() logged into the event log, so its failing at that point. I DO get the Exception error logged into the event log so i know the void is being called.
Simple WebService code
the service is installed as LocalSystem, i have tried running as domain admin, and domain user with no luck (DOMAIN\UserAccount and provided static password)
Thanks for any help you can provide!
Do i auth the webservice (this is all on an INTRAnet, btw) or do i auth the windows service? (IIS with IWA)
Right now this is being run from my workstation, not the webserver, and the Web Reference is populating and intellisensing fine in the designer. Should i install the service on the webserver??
in the Scheduler service code
Code:
private void RunCommands(object state)
{
try
{
ContactManagement.Schedule job = new ContactManagement.Schedule();
job.Credentials = System.Net.CredentialCache.DefaultCredentials;
LogEvent(job.UserAccount(), EventLogEntryType.Information);
job.RunJob();
LogEvent("Made it happen", EventLogEntryType.Information);
}
catch (Exception ex)
{
LogEvent(ex.Message, EventLogEntryType.Error);
}
}
protected override void OnStart(string[] args)
{
TimerCallback timerDG = new TimerCallback(RunCommands);
serviceTimer = new Timer(timerDG, null, 1000, _interval);
base.OnStart(args);
}
i dont get the job.UserAccount() logged into the event log, so its failing at that point. I DO get the Exception error logged into the event log so i know the void is being called.
Simple WebService code
Code:
namespace ContactManagement.Services
{
[WebService(Namespace = "[URL unfurl="true"]http://tempuri.org/")[/URL]]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Schedule : WebService
{
private static Mutex mut = new Mutex(false, "JobSchedulerMutex");
[WebMethod]
public void RunJob()
{
mut.WaitOne();
try
{
email.sendEmail("services@domain.local", "Adams App", "adamr@domain.com", "Scheduled Email", "Hello");
}
finally
{ mut.ReleaseMutex(); }
}
[WebMethod]
public string UserAccount()
{
return "Service User: " + Thread.CurrentPrincipal.Identity.Name;
}
}
}
the service is installed as LocalSystem, i have tried running as domain admin, and domain user with no luck (DOMAIN\UserAccount and provided static password)
Code:
//# Service Account Information
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
serviceProcessInstaller.Username = null;
serviceProcessInstaller.Password = null;
Thanks for any help you can provide!