NetJavaScriptFlex

 2023-09-16 阅读 18 评论 0

摘要:一、建立webservice using System;using System.Linq;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;using System.Xml.Linq; [WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProf

一、建立webservice

 

using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //如果使用设计的组件,请取消注释以下行
        //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    [WebMethod]
    public double Calc(double r)
    {
        return 2 * r * Math.PI;
    } 
   
}

 

 

二、Flex Bulider中

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
 <![CDATA[
  private function calc():void
  {
   var l:Number;
   l=Number(radius.text)*2*Math.PI;
   grith.text=String(l);
  }
 ]]>
</mx:Script>
<mx:WebService id="calcService" wsdl="http://localhost:12374/Test1/Service.asmx?WSDL"  useProxy="false">
 <mx:operation name="Calc">
  <mx:request>
   <r>{radius.text}</r>
  </mx:request>
 </mx:operation>
</mx:WebService>

 <mx:Button x="390" y="161" label="Button" click="calc();"/>
 <mx:TextInput x="213" y="161" id="radius"/>
 <mx:Text x="213" y="215" text="圆周长:"/>
 <mx:Text x="251" y="215" text="{calcService.Calc.lastResult}" id="grith"/>
 <mx:Button x="493" y="161" label="NET互操作" click="calcService.Calc.send();"/>
 
</mx:Application>

 

转载于:https://www.cnblogs.com/yidianfeng/archive/2011/10/24/2222878.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/66127.html

上一篇:iphone编译警告
下一篇:图片查看器C#

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息