2006-08-01

WebService Behavior 学习心得

来源: CSDN 作者:Venus 评论 0 条
  iCallID = service.MyMath.callService(mathResults, callObj); mathResults(iCallID); } function doSubtraction(y, x){ // 异步调用,这是系统默认的调用方式(the default) oSPAN.innerText = y " - " x " = "; // 调用Subtract // 使用回调函数"mathResults"调用 iCallID = service.MyMath.callService(mathResults, "Subtract", y, x); } function mathResults(result){ // If there is an error, and the call came from the call() in init() if(result.error){ // Pull the error information from the event.result.errorDetail properties var xfaultcode = result.errorDetail.code; var xfaultstring = result.errorDetail.string; var xfaultsoap = result.errorDetail.raw; oSPAN.innerText = xfaultcode " " xfaultstring " " xfaultsoap; }// If there was no error else{ // Show the arithmetic oSPAN.innerText = result.value; } } </SCRIPT> </HEAD> <body onload="init()">
//设置Div元素绑定WebService服务,在这里可以添加onresult="onWSresult()",在该事件中处理调用结果

<div id="service" style="behavior:url(../webservice.htc)"></div>

<BR><BR>

Equation : <SPAN id="oSPAN"></SPAN>

<BR><BR>

<BUTTON id="doAddButton" onclick="doAdd(5, 6);">Do Add function of 5 and 6</BUTTON>

<BUTTON onclick="doSubtraction(6, 5);">Do Subtraction of 6 and 5</BUTTON>

</body>

一些总结:

  1. 客户端必须包含Webservice.htc,将Webservice.htc放在服务器可访问的目录下,可以保证IE浏览器浏览时自动下载该文件,该过程对客户来说是透明的,但是使用其他的浏览器可能会无法使用该功能。
  2. 获取调用结果有两种方式
    使用事件捕捉:在Html标记中添加 onresult="onWSresult()",如:
    <SCRIPT language="JavaScript">
    var iCallID;

    function init()
    {
    service.useService("/services/math.asmx?WSDL","MyMath");
    iCallID = service.MyMath.callService("add",5,6);
    共3页: 上一页 [1] 2 [3] 下一页
(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:鼠标在文本上移动时层的显示与消失  
下一篇:关于iframe的透明背景
    评论加载中…

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号