weixin_33749131 2011-11-03 15:10 采纳率: 0%
浏览 85

从javascript调用到WCF

I created a WCF service:

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);
        }
    }
}

That implements this contract:

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);
    }
}

And this is in the 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>

And in the masterPage:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    <Services>
        <asp:ServiceReference Path="~/MatchesListService.svc" />
    </Services>
</asp:ScriptManager>

I am trying to call my WCF service from my javascript code:

ISTL.IMatchesListService.AcceptRequestToChangeMatchTime(matchId);

But calling the WCF fails. When I debug with FireBug, when I reach the calling line, then the error occurs. matchId is a valid value. FireBug recognizes the ISTL namespace, but regarding IMatchesListService it says its value is 'undefiend'.

Someone know what I'm doing wrong ?

Thanks for helping !

  • 写回答

1条回答 默认 最新

  • weixin_33725807 2011-11-04 07:01
    关注

    you need to pass onSuccess , onFailure delgate check this WCF Newbie Question: Calling Methods from JavaScript … I would recommend you to close this question.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器