怎样用js调用wcf服务

怎样用js调用wcf服务,第1张

需要System.Web.Extensions.dll(可能需要AJAXExtensionsToolbox.dll)

网上下载ASPAJAXExtSetup

使用的时候把上面的2个dll放到bin下,并添加引用(一般服务器没有安装ASPAJAXExtSetup)

==============================

Web服务

==============================

using System

using System.Web

using System.Collections

using System.Web.Services

using System.Web.Services.Protocols

using System.Web.Script.Services

using System.Data

using System.Text.RegularExpressions

/// <summary>

/// addComment 的摘要说明

/// </summary>

[WebService(Namespace = "http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[ScriptService]

public class manageComment : System.Web.Services.WebService

{

[WebMethod(EnableSession = true)]

public string CommentByID(string userName)

{

//支持session

}

public string DeleteHostComment(int replayID)

{

}

}

aspx页面设置web服务文件的路径

===============================

<asp:ScriptManager ID="smAddComment" runat="server">

<Services>

<asp:ServiceReference Path="~/WS/manageComment.asmx" />

</Services>

</asp:ScriptManager>

js调用

=================================

manageComment.CommentByID('名称')

manageComment.DeleteHostComment(1)

tip:调用的格式->[命名空间.]类名.方法名(参数1[,参数2……])

wpf是个很强大的开发平台(类似于C#winform,)既可以做前台(编码类似与Html语言,采用xaml格式)也可以做后台(C#逻辑代码)。wpf的前台很强大,即可以在BS用也可以在CS用。总的来说,wpf界面上可以做的很美观,但离底层有缘了一点,功能上会比Winform差些或者说是困难点。

wcf我也不清楚没搞过。你可以看下百度百科的资料http://baike.baidu.com/view/1140438.html?wtp=tt


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7294492.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-03
下一篇 2023-04-03

发表评论

登录后才能评论

评论列表(0条)

保存