我有兩臺相同的服務器。 Win2k3。我有一個Web服務將電子郵件和使用該服務的應用程序排隊。兩者都使用相同的文件夾結構,權限和IIS設置在兩臺機器上進行託管。一個叫做「測試」,另一個叫做「prod」。Web服務在一臺服務器上失敗(401未授權),但在另一臺服務器上失敗
理想情況下,prod上的應用程序將指向產品上的ws。但是,如果是這樣的話,我碰到下面的錯誤頁面:
Server Error in '/Apps/UTMv1' Application.
The request failed with HTTP status 401: Unauthorized. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[WebException: The request failed with HTTP status 401: Unauthorized.]
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) in C:\Documents and Settings\username\Desktop\Projects\utm\utm\Web References\AppManagerEmailer\Reference.cs:93 utm.test.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\username\Desktop\Projects\utm\utm\test.aspx.cs:23 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
如果對測試WS上PROD點的應用程序,它的工作原理。另外,如果測試中的應用程序指向了產品上的ws,它就可以工作。
爲了好玩,我試着在另一個應用程序中使用ws。它的表現與原始應用程序相同。
此外,我有其他的Web服務運行prod上正常工作。這是唯一導致問題的原因。
這是我在應用程序中使用新的向上郵件器和隊列的郵件代碼:
Emailer e = new Emailer();
e.Credentials = System.Net.CredentialCache.DefaultCredentials;
int intEmailId = e.AddToQueue(fromEmail, toEmail, subject, body, 103, true);
下面是我的web服務代碼:
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;
}
}
}
那麼,做什麼你認爲可能是問題?
聽起來像那裏可能是一個配置問題。如果沒有答案解決您的問題,請嘗試發佈到serverfault。 – 2009-12-28 15:01:33