使用flex或actionscript使用SOAP和WSDL连接到远程Web服务

时间:2011-08-16 15:33:55

标签: actionscript-3 flash-builder

要求是使用Flex或ActionScript使用Soap和wsdl从Web服务获取名为getIncidentList()的方法。 任何人都可以帮助我,我有一个不起作用的代码:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:WebService id="DirectoryService"
         wsdl="http://cmuicds.rutgers.edu/uicds/core/ws/services/DirectoryService.wsdl" 
         useProxy="false"   
         showBusyCursor="true"
         result="onResult(event)" 
         fault="onFault(event)">    
      </mx:WebService>

      <mx:ApplicationControlBar dock="true">
      <mx:Button id="button"
            label="get incidents from web service"
            click="button_click()"/>
      <mx:ComboBox id="cmb" dataProvider="{zipfls}" labelField="name" width="241" height="24"/>
      </mx:ApplicationControlBar>


      <mx:Script>
        <![CDATA[
        import mx.controls.Alert;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            import mx.utils.ObjectUtil;
            import mx.collections.ArrayCollection;

            [Bindable] private var zipfls:ArrayCollection;
            private var flag:Boolean;

        private function button_click():void 
        {
            //Alert.show("Hi");
            //DirectoryService.GetIncidentList.send();
            DirectoryService.GetIncidentList();
            flag = DirectoryService.canLoadWSDL();
            //flag = DirectoryService.hasOwnProperty();
            //Alert.show("Testing....." + flag);
            //Alert.show("Description " +DirectoryService.operations);

            } 

             private function onResult(evt:ResultEvent):void 
            {
            zipfls = new ArrayCollection();                 
            //textArea.text = ObjectUtil.toString(evt.result);
            zipfls = evt.result as ArrayCollection;
            Alert.show("Is data comming in?" + zipfls.length);
            }

            private function onFault(evt:FaultEvent):void 
            {
            Alert.show(evt.type);

            }


           ]]>
        </mx:Script>

 </mx:Application>

1 个答案:

答案 0 :(得分:0)

我认为你没有正确地调用方法

和事件 button_click 应为

    private function button_click():void 
    {
        DirectoryService.GetIncidentList();

    }  

即。 发送不应该使用。

另见Using WebService components

希望有所帮助