我正在尝试使用 Web 服务返回 FullCallendar Resource 请求的资源的 json 列表:
这是网络服务类:
/// <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: [
{
我不确定为什么这不起作用。也许我不懂网络服务?
在这个例子中,他们调用 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