Web サービスを使用して、FullCallendar リソースが要求しているリソースの json リストを返そうとしています:
Web サービス クラスは次のとおりです。
/// <summary>
/// Summary description for CalendarServices
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.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 CalendarServices : System.Web.Services.WebService
{
public CalendarServices()
{
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetEmployees()
{
List<object> eventList = new List<object>();
var emps = ResourceManager.GetAllEmployees();
foreach (Employee e in emps)
{
eventList.Add(
new
{
id = e.EmployeID.ToString(),
name = e.EmployeName
}
);
}
JavaScriptSerializer js = new JavaScriptSerializer();
string strJSON = js.Serialize(eventList);
return strJSON;
}
}
これが呼ばれる場所です:
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: ''
},
defaultView: 'resourceNextWeeks',
numberOfWeeks: 5,
weekends: false,
editable: true,
selectable: true,
minTime: 8,
maxTime: 16,
refetchResources: true,
selectHelper: true,
resources: 'CalendarServices.asmx/GetEmployees'
,
events: [
{
なぜこれが機能しないのかわかりません。多分私はWebサービスを理解していませんか?
この例では、単にエコーする resources.php を呼び出します。
基本的に私が望むのは、CalendarServices.asmx/GetEmployees にアクセスする場合です。
ブラウザでこれを見たい:
[
{
"name":"Resource 2",
"id":"resource2"
},
{
"name":"Resource 1",
"id":"resource1"}
]
プレーンテキストだけで十分です。現在、ブラウザでこの URL を試すと、クラッシュします。
私に何ができる?
ありがとう
クラッシュ:
Request format is unrecognized for URL unexpectedly ending in '/GetEmployees'.
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.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetEmployees'.
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:
[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetEmployees'.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +489333
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +226
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +145
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155