2011-04-15 31 views
1

我有這個工作,現在不是。我們有多個開發人員在開發這個項目,但是代碼看起來像是在工作的時候。我在另一篇文章中略微提到URL重寫可能會導致一個問題,但如果問題出在這個問題上或者如果有修復的話,它就不會出現。可悲的是這是一個網站(而不是Web應用程序),但它工作。另一個可能的問題是我們正在使用Ektron CMS。再次,它正在處理所有這些變量,除了網址的別名/重寫,所以這可能是問題。服務器方法'xxx'失敗

javascript方面在intellisense中看到了方法。我甚至有一個警告,告訴我方法,所以它知道它的存在。但我得到的消息:服務器方法'LookupCourseItems'失敗。

<script language="javascript" type="text/javascript"> 
    function CourseLookup(ItemLookup, ResultID) { 
    alert('Attempting to look up: ' + ItemLookup); 
    var service = new AjaxDataServices.AjaxService(); 
    service.LookupCourseItems(ItemLookup, onCourseLookupSuccess, onCourseLookupFailure, ResultID); 
    } // CourseLookup - Method 

    function onCourseLookupSuccess(result, userContext) { 
    var o = document.getElementById(userContext); 
    if (o != null) { 
     alert('Success!'); 
     o.outerHTML = result; 
    } else { 
     alert('Unable to find: ' + userContext); 
    } // if we were able to find the element to fill 
    } // onCourseLookupSuccess - Method 

    function onCourseLookupFailure(result) { 
    alert(result.get_message()); 
    alert("StackTrace: " + result.get_stackTrace()); 
    alert("StatusCode: " + result.get_statusCode()); 
    alert("ErrorObject: " + result.get_errorObject()); 
    } // onCourseLookupFailure - Method 

下面是使用ScriptManager:

<asp:ScriptManager ID="ScriptManager" runat="server"> 
    <Services> 
    <asp:ServiceReference Path="~/AjaxService.svc" /> 
    </Services> 
</asp:ScriptManager> 

這裏的服務:

[ServiceContract(Namespace = "AjaxDataServices")] 
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
public class AjaxService { 
    [OperationContract] 
    public string LookupCourseItems(string LookupPair) { 
    CourseRepository Repository = new CourseRepository(ConfigurationManager.ConnectionStrings["CAMS"].ConnectionString, 7); 
    string CourseID = ""; 
    string SemesterName = ""; 

    if (LookupPair.Contains(":")) { 
     string[] Parts = LookupPair.Split(new char[] { ':' }, 
     StringSplitOptions.RemoveEmptyEntries); 
     CourseID = Parts[0]; 
     SemesterName = Parts[1]; 
    } else { 
     CourseID = LookupPair; 
    } // if the Semester was also given 

    Course Item = Repository.GetSingleCourseInformation(CourseID, SemesterName); 

    if (string.IsNullOrWhiteSpace(SemesterName)) 
     return Item.ToHTML(); 
    else 
     return Item.Semesters.Where(s => s.Name == SemesterName).SingleOrDefault().ToHTML(); 
    } // LookupCourseItems - Method 

運行時,最初的 「Attemping查找:1234」 工程。 然後onCourseLookupFailure方法被調用,並在本文的標題中轉述消息。 然後堆棧跟蹤是空 的是的StatusCode 404 而ErrorObject爲空。

404使我覺得它找不到服務。這似乎也是合乎邏輯的,因爲當我在服務器端進行調試時,它永遠不會到達Web服務。

任何建議或想法?

回答

1

我建議使用名爲「Fiddler」的工具,它是一個HTTP調試代理,它可以讓你看到來自客戶端/服務器的HTTP請求。

它可以幫助你診斷髮生了什麼事您的要求。

相關問題