我有两台相同的服务器。都是win2k3。我有一个将电子邮件排队的 Web 服务和一个使用该服务的应用程序。两者都使用相同的文件夹结构、权限和 IIS 设置托管在两台计算机上。一个称为“测试”,另一个称为“产品”。
理想情况下,prod 上的应用程序将指向 prod 上的 ws。但是,在这种情况下,我会收到以下错误页面:
“/Apps/UTMv1”应用程序中的服务器错误。
请求失败,HTTP 状态为 401:未授权。说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Net.WebException:请求失败,HTTP 状态 401:未授权。
源错误:
在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。
堆栈跟踪:
[WebException:请求失败,HTTP 状态 401:未授权。]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +431201 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204 utm. AppManagerEmailer.Emailer.AddToQueue(String txtFrom, String txtTo, String txtSubject, String txtBody, Int32 intAppId, Boolean blnIsBodyHtml) 在 C:\Documents and Settings\username\Desktop\Projects\utm\utm\Web References\AppManagerEmailer\Reference.cs :93 utm.test.Page_Load(Object sender, EventArgs e) 在 C:\Documents and Settings\username\Desktop\Projects\utm\utm\test.aspx.cs:23 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,对象 o,对象 t,EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy。回调(对象发送者,EventArgs e)+35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint) +627版本信息:Microsoft .NET Framework 版本:2.0.50727.3053;ASP.NET 版本:2.0.50727.3053
如果 prod 上的应用程序指向测试中的 ws,它就可以工作。此外,如果测试上的应用程序指向产品上的 ws,它就可以工作。
为了好玩,我尝试在另一个应用程序中使用 ws on prod。它的行为与原始应用程序相同。
此外,我还在 prod 上运行了其他可以正常工作的 Web 服务。这是唯一一个似乎引起问题的问题。
这是我在应用程序中使用的代码来更新电子邮件和排队电子邮件:
Emailer e = new Emailer();
e.Credentials = System.Net.CredentialCache.DefaultCredentials;
int intEmailId = e.AddToQueue(fromEmail, toEmail, subject, body, 103, true);
这是我的网络服务的代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Net.Mail;
using System.Collections.Generic;
namespace AppManager.WebServices
{
/// <summary>
/// Summary description for emailer
/// </summary>
[WebService(Namespace = "http://www.mydomain.com/apps/appManager/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Emailer : System.Web.Services.WebService
{
[WebMethod]
public int AddToQueue(string txtFrom, string txtTo, string txtSubject, string txtBody, int intAppId, bool blnIsBodyHtml)
{
Email e = new Email()
{
From = new MailAddress(txtFrom),
Subject = txtSubject,
Body = txtBody,
IsBodyHtml = blnIsBodyHtml,
AppId = intAppId
};
e.To.Add(txtTo);
e.AddToQueue();
return e.Id;
}
}
}
那么,您认为可能是什么问题?