【发布时间】:2011-11-04 15:01:03
【问题描述】:
我创建了一个 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>
在母版页中:
<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'。
有人知道我在做什么错吗?
感谢您的帮助!
【问题讨论】:
-
你需要通过 onSuccess , onFailure delgate 检查这个stackoverflow.com/questions/712238/… 我建议你关闭这个问题。