Flex asp.net通过webservice通信

在我的RIA系统中,先后使用过Flourinfa、Weborb代理,后又使用HttpServicew与asp.net通信交互,但Flex的ArrayCollection类本身有点问题,不能实现特定的需要,所以采用vs2008 Webservice方式。先把我的测试代码贴出来

C#代码:

using System.Web;
using System.Web.Services;

namespace AvFashionWebService
{
    /// <summary>
    /// Service1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://192.168.1.188/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }
}

 

flex调用代码:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Script>
  <![CDATA[
   import mx.rpc.events.FaultEvent;
   import mx.rpc.events.ResultEvent;
   import mx.controls.Alert;
   private function onResult(event:ResultEvent):void
   {
       Alert.show("called");
       output.text="返回结果:"+event.result;
   }

   private function onFault( event:FaultEvent) : void
   {
       
       output.text ="调用失败:" +event.fault.message.toString();
   }
   private function ServiceCall():void
   {
    Alert.show("call");
    service.HelloWorld();
   }
  ]]>
 </mx:Script>
 <mx:WebService
  id="service"
    wsdl="http://192.168.1.188/test/Service1.asmx?WSDL"
       showBusyCursor="true"
       useProxy="false">
       <mx:operation name="HelloWorld" result="onResult(event)" fault="onFault(event)"/>
    </mx:WebService>  
 <mx:Button x="388" y="124" label="Call  Webservice" height="44" fontSize="12" click="ServiceCall()"/>
 <mx:TextArea x="10" y="124" width="358" id="output"/>
</mx:Application>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值