我创建了一个WCF服务:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace ISTL
{
public class MatchesListService : IMatchesListService
{
public bool AcceptRequestToChangeMatchTime(int matchId)
{
return MatchesListManager.AcceptRequestToChangeMatchTime(matchId);
}
}
}
实施此合同:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace ISTL
{
[ServiceContract(Namespace = "ISTL")]
public interface IMatchesListService
{
[OperationContract]
bool AcceptRequestToChangeMatchTime(int matchId);
}
}
这是在web.config中:
<system.serviceModel>
<services>
<service name="ISTL.MatchesListService">
<endpoint binding="webHttpBinding" contract="ISTL.IMatchesListService"></endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior>
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
在masterPage中:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
<Services>
<asp:ServiceReference Path="~/MatchesListService.svc" />
</Services>
</asp:ScriptManager>
我正在尝试从我的javascript代码调用我的WCF服务:
ISTL.IMatchesListService.AcceptRequestToChangeMatchTime(matchId);
但是调用WCF失败了。 当我使用FireBug进行调试时,当我到达调用行时,就会发生错误。 matchId是一个有效值。 FireBug识别ISTL命名空间,但是关于IMatchesListService,它表示它的值是'undefiend'。
有人知道我做错了吗?
感谢您的帮助!
答案 0 :(得分:0)
你需要传递onSuccess,onFailure delgate检查这个WCF Newbie Question: Calling Methods from JavaScript ...我建议你关闭这个问题。