CTOCIO IT专家网

天极传媒 比特网 | 天极网 | IT专家网 | IT商网 | 52PK游戏网 | 手机天极 | IT分众 |
IT专家网搜索

您现在的位置: IT专家网 > Web服务子站 > WebService领域

在ASP.NET Atlas中调用Web Service

作者: Dflying,  出处:中国IT实验室, 责任编辑: 包春林, 
2008-04-10 04:00
  Atlas Framework中包含了对AJAX调用的封装,让您可以很方便的在客户端通过JavaScript调用服务器端方法。

  Atlas Framework中包含了对AJAX调用的封装,让您可以很方便的在客户端通过JavaScript调用服务器端方法。在本篇文章中,我将解释一下如何使用Atlas调用服务器端Web Service。

  使用Atlas,我们只需要如下步骤即可调用服务器端Web Service:

  在Web Service的方法上加上[WebMethod]属性。 在ASPX页面上的ScriptManager中添加对这个Web Service的引用。  只需以上两步,Atlas会在运行时为您生成相应的mash up,让您可在客户端JavaScript中通过WebServiceClassName.ServiceMethodName()调用该方法。

  让我们先来看一个最简单的例子,调用服务器端Web Service得到两个数的和:

  首先建立一个Web Service:SimpleWebService.asmx,并在其中添加一个Service Method,不要忘记标记为[WebMethod]哦:

  

[WebMethod]

  public int AddInt(int int1, int int2)

  {

  return int1 + int2;

  }

        然后再ASPX页面上的ScriptManager中添加对该Web Service的引用:

  

< atlas:ScriptManager ID="ScriptManager1" runat="server">

  < Services>

  < atlas:ServiceReference Path="SimpleWebService.asmx" />

  < /Services>

  < /atlas:ScriptManager>

        添加点HTML Code,让用户输入两个整数:

     

Pass simple type to web service - add the two integers:< br />

  < input id="int1" type="text" value="1" size="3" />+

  < input id="int2" type="text" value="2" size="3" />=

  < input id="btnAddInt" type="button" value="?" onclick="return btnAddInt_onclick()" />< br />

  < br />

共4页。 1 2 3 4 :

网友评论

笔名 
请您注意:遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。    IT专家网友拥有管理笔名和留言的一切权利。
  • 周排行榜
  • 月排行榜

邮件订阅

       
天极服务 | 关于我们 | 网站律师 | 加入我们 | 联系我们 | 广告业务 | 友情链接 | 我要挑错
All Rights Reserved, Copyright 2004-2007, ChinaByte
渝ICP证B2-20030003号 如有意见请与我们联系 powered by 天极内容管理平台CMS4i